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