< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/JvmtiAddPath.java

Print this page

 93 
 94     public static void main(String[] args) throws Exception {
 95         buildTestModule();
 96         JarBuilder.build("jvmti_app", "JvmtiApp", "ExtraClass");
 97         JarBuilder.build(true, "WhiteBox", "jdk/test/whitebox/WhiteBox");
 98 
 99         // In all the test cases below, appJar does not contain Hello.class. Instead, we
100         // append JAR file(s) that contain Hello.class to the boot classpath, the app
101         // classpath, or both, and verify that Hello.class is loaded by the expected ClassLoader.
102         String appJar = TestCommon.getTestJar("jvmti_app.jar");         // contains JvmtiApp.class
103         String addappJar = mainJar.toString();  // contains Main.class
104         String addbootJar = mainJar.toString(); // contains Main.class
105         String twoAppJars = appJar + File.pathSeparator + addappJar;
106         String modulePath = "--module-path=" + moduleDir.toString();
107         String wbJar = TestCommon.getTestJar("WhiteBox.jar");
108         use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
109 
110         OutputAnalyzer output = TestCommon.createArchive(
111                                     appJar,
112                                     TestCommon.list("JvmtiApp", "ExtraClass", MAIN_CLASS),

113                                     use_whitebox_jar,
114                                     modulePath);
115         TestCommon.checkDump(output);
116 
117         System.out.println("Test case 1: not adding module path - Hello.class should not be found");
118         run(check_appcds_enabled, appJar,
119             "-Xlog:class+load", "JvmtiApp", "noadd", MAIN_CLASS); // appcds should be enabled
120 
121         System.out.println("Test case 2: add to boot classpath only - should find Hello.class in boot loader");
122         run(check_appcds_disabled, appJar,
123             "-Xlog:class+load=trace",
124             modulePath,
125             "JvmtiApp", "bootonly", addbootJar, MAIN_CLASS); // appcds should be disabled
126 
127         System.out.println("Test case 3: add to app classpath only - should find Hello.class in app loader");
128         run(appJar, modulePath,
129             "JvmtiApp", "apponly", addappJar, MAIN_CLASS);
130 
131         System.out.println("Test case 4: add to boot and app paths - should find Hello.class in boot loader");
132         run(appJar, modulePath,
133             "JvmtiApp", "appandboot", addbootJar, addappJar, MAIN_CLASS);
134 
135         System.out.println("Test case 5: add to app using -cp, but add to boot using JVMTI - should find Hello.class in boot loader");
136         run(appJar, modulePath,
137             "JvmtiApp", "bootonly", addappJar, MAIN_CLASS);
138 
139         System.out.println("Test case 6: add to app using AppCDS, but add to boot using JVMTI - should find Hello.class in boot loader");
140         output = TestCommon.createArchive(
141                      appJar, TestCommon.list("JvmtiApp", "ExtraClass"),
142                      use_whitebox_jar,

143                      modulePath);
144         TestCommon.checkDump(output);
145         run(twoAppJars, modulePath,
146             "JvmtiApp", "bootonly", addappJar, MAIN_CLASS);
147 
148         System.out.println("Test case 7: add to app using AppCDS, no JVMTI calls - should find Hello.class in app loader");
149         run(twoAppJars, modulePath,
150             "JvmtiApp", "noadd-appcds", MAIN_CLASS);
151     }
152 }

 93 
 94     public static void main(String[] args) throws Exception {
 95         buildTestModule();
 96         JarBuilder.build("jvmti_app", "JvmtiApp", "ExtraClass");
 97         JarBuilder.build(true, "WhiteBox", "jdk/test/whitebox/WhiteBox");
 98 
 99         // In all the test cases below, appJar does not contain Hello.class. Instead, we
100         // append JAR file(s) that contain Hello.class to the boot classpath, the app
101         // classpath, or both, and verify that Hello.class is loaded by the expected ClassLoader.
102         String appJar = TestCommon.getTestJar("jvmti_app.jar");         // contains JvmtiApp.class
103         String addappJar = mainJar.toString();  // contains Main.class
104         String addbootJar = mainJar.toString(); // contains Main.class
105         String twoAppJars = appJar + File.pathSeparator + addappJar;
106         String modulePath = "--module-path=" + moduleDir.toString();
107         String wbJar = TestCommon.getTestJar("WhiteBox.jar");
108         use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
109 
110         OutputAnalyzer output = TestCommon.createArchive(
111                                     appJar,
112                                     TestCommon.list("JvmtiApp", "ExtraClass", MAIN_CLASS),
113                                     "-XX:-PreloadSharedClasses",
114                                     use_whitebox_jar,
115                                     modulePath);
116         TestCommon.checkDump(output);
117 
118         System.out.println("Test case 1: not adding module path - Hello.class should not be found");
119         run(check_appcds_enabled, appJar,
120             "-Xlog:class+load", "JvmtiApp", "noadd", MAIN_CLASS); // appcds should be enabled
121 
122         System.out.println("Test case 2: add to boot classpath only - should find Hello.class in boot loader");
123         run(check_appcds_disabled, appJar,
124             "-Xlog:class+load=trace",
125             modulePath,
126             "JvmtiApp", "bootonly", addbootJar, MAIN_CLASS); // appcds should be disabled
127 
128         System.out.println("Test case 3: add to app classpath only - should find Hello.class in app loader");
129         run(appJar, modulePath,
130             "JvmtiApp", "apponly", addappJar, MAIN_CLASS);
131 
132         System.out.println("Test case 4: add to boot and app paths - should find Hello.class in boot loader");
133         run(appJar, modulePath,
134             "JvmtiApp", "appandboot", addbootJar, addappJar, MAIN_CLASS);
135 
136         System.out.println("Test case 5: add to app using -cp, but add to boot using JVMTI - should find Hello.class in boot loader");
137         run(appJar, modulePath,
138             "JvmtiApp", "bootonly", addappJar, MAIN_CLASS);
139 
140         System.out.println("Test case 6: add to app using AppCDS, but add to boot using JVMTI - should find Hello.class in boot loader");
141         output = TestCommon.createArchive(
142                      appJar, TestCommon.list("JvmtiApp", "ExtraClass"),
143                      use_whitebox_jar,
144                      "-XX:-PreloadSharedClasses",
145                      modulePath);
146         TestCommon.checkDump(output);
147         run(twoAppJars, modulePath,
148             "JvmtiApp", "bootonly", addappJar, MAIN_CLASS);
149 
150         System.out.println("Test case 7: add to app using AppCDS, no JVMTI calls - should find Hello.class in app loader");
151         run(twoAppJars, modulePath,
152             "JvmtiApp", "noadd-appcds", MAIN_CLASS);
153     }
154 }
< prev index next >