< prev index next >

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

Print this page

 58         opts = TestCommon.concat(opts, args);
 59         TestCommon.run(opts).assertNormalExit(extra_matches);
 60     }
 61 
 62     public static void main(String[] args) throws Exception {
 63         JarBuilder.build("jvmti_addboot", "Hello");
 64         JarBuilder.build("jvmti_addapp", "Hello");
 65         JarBuilder.build("jvmti_app", "JvmtiApp", "ExtraClass");
 66         JarBuilder.build(true, "WhiteBox", "jdk/test/whitebox/WhiteBox");
 67 
 68         // In all the test cases below, appJar does not contain Hello.class. Instead, we
 69         // append JAR file(s) that contain Hello.class to the boot classpath, the app
 70         // classpath, or both, and verify that Hello.class is loaded by the expected ClassLoader.
 71         String appJar = TestCommon.getTestJar("jvmti_app.jar");         // contains JvmtiApp.class
 72         String addappJar = TestCommon.getTestJar("jvmti_addapp.jar");   // contains Hello.class
 73         String addbootJar = TestCommon.getTestJar("jvmti_addboot.jar"); // contains Hello.class
 74         String twoAppJars = appJar + File.pathSeparator + addappJar;
 75         String wbJar = TestCommon.getTestJar("WhiteBox.jar");
 76         use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
 77 
 78         TestCommon.testDump(appJar, TestCommon.list("JvmtiApp", "ExtraClass"), use_whitebox_jar);
 79 
 80         System.out.println("Test case 1: not adding any paths - Hello.class should not be found");
 81         run(check_appcds_enabled, appJar, "-Xlog:class+load", "JvmtiApp", "noadd"); // appcds should be enabled
 82 
 83         System.out.println("Test case 2: add to boot classpath only - should find Hello.class in boot loader");
 84         run(check_appcds_disabled, appJar, "-Xlog:class+load", "JvmtiApp", "bootonly", addbootJar); // appcds should be disabled
 85 
 86         System.out.println("Test case 3: add to app classpath only - should find Hello.class in app loader");
 87         run(appJar, "JvmtiApp", "apponly", addappJar);
 88 
 89         System.out.println("Test case 4: add to boot and app paths - should find Hello.class in boot loader");
 90         run(appJar, "JvmtiApp", "appandboot", addbootJar, addappJar);
 91 
 92         System.out.println("Test case 5: add to app using -cp, but add to boot using JVMTI - should find Hello.class in boot loader");
 93         run(twoAppJars, "JvmtiApp", "bootonly", addappJar);
 94 
 95         System.out.println("Test case 6: add to app using AppCDS, but add to boot using JVMTI - should find Hello.class in boot loader");
 96         TestCommon.testDump(twoAppJars, TestCommon.list("JvmtiApp", "ExtraClass", "Hello"), use_whitebox_jar);
 97         if (!TestCommon.isDynamicArchive()) {
 98             // skip for dynamic archive, the Hello class will be loaded from
 99             // the dynamic archive
100             run(twoAppJars, "JvmtiApp", "bootonly", addappJar);
101         }
102 
103         System.out.println("Test case 7: add to app using AppCDS, no JVMTI calls - should find Hello.class in app loader");
104         run(twoAppJars, "JvmtiApp", "noadd-appcds");
105     }
106 }

 58         opts = TestCommon.concat(opts, args);
 59         TestCommon.run(opts).assertNormalExit(extra_matches);
 60     }
 61 
 62     public static void main(String[] args) throws Exception {
 63         JarBuilder.build("jvmti_addboot", "Hello");
 64         JarBuilder.build("jvmti_addapp", "Hello");
 65         JarBuilder.build("jvmti_app", "JvmtiApp", "ExtraClass");
 66         JarBuilder.build(true, "WhiteBox", "jdk/test/whitebox/WhiteBox");
 67 
 68         // In all the test cases below, appJar does not contain Hello.class. Instead, we
 69         // append JAR file(s) that contain Hello.class to the boot classpath, the app
 70         // classpath, or both, and verify that Hello.class is loaded by the expected ClassLoader.
 71         String appJar = TestCommon.getTestJar("jvmti_app.jar");         // contains JvmtiApp.class
 72         String addappJar = TestCommon.getTestJar("jvmti_addapp.jar");   // contains Hello.class
 73         String addbootJar = TestCommon.getTestJar("jvmti_addboot.jar"); // contains Hello.class
 74         String twoAppJars = appJar + File.pathSeparator + addappJar;
 75         String wbJar = TestCommon.getTestJar("WhiteBox.jar");
 76         use_whitebox_jar = "-Xbootclasspath/a:" + wbJar;
 77 
 78         TestCommon.testDump(appJar, TestCommon.list("JvmtiApp", "ExtraClass"), "-XX:-PreloadSharedClasses", use_whitebox_jar);
 79 
 80         System.out.println("Test case 1: not adding any paths - Hello.class should not be found");
 81         run(check_appcds_enabled, appJar, "-Xlog:class+load", "JvmtiApp", "noadd"); // appcds should be enabled
 82 
 83         System.out.println("Test case 2: add to boot classpath only - should find Hello.class in boot loader");
 84         run(check_appcds_disabled, appJar, "-Xlog:class+load", "JvmtiApp", "bootonly", addbootJar); // appcds should be disabled
 85 
 86         System.out.println("Test case 3: add to app classpath only - should find Hello.class in app loader");
 87         run(appJar, "JvmtiApp", "apponly", addappJar);
 88 
 89         System.out.println("Test case 4: add to boot and app paths - should find Hello.class in boot loader");
 90         run(appJar, "JvmtiApp", "appandboot", addbootJar, addappJar);
 91 
 92         System.out.println("Test case 5: add to app using -cp, but add to boot using JVMTI - should find Hello.class in boot loader");
 93         run(twoAppJars, "JvmtiApp", "bootonly", addappJar);
 94 
 95         System.out.println("Test case 6: add to app using AppCDS, but add to boot using JVMTI - should find Hello.class in boot loader");
 96         TestCommon.testDump(twoAppJars, TestCommon.list("JvmtiApp", "ExtraClass", "Hello"), "-XX:-PreloadSharedClasses", use_whitebox_jar);
 97         if (!TestCommon.isDynamicArchive()) {
 98             // skip for dynamic archive, the Hello class will be loaded from
 99             // the dynamic archive
100             run(twoAppJars, "JvmtiApp", "bootonly", addappJar);
101         }
102 
103         System.out.println("Test case 7: add to app using AppCDS, no JVMTI calls - should find Hello.class in app loader");
104         run(twoAppJars, "JvmtiApp", "noadd-appcds");
105     }
106 }
< prev index next >