8224548: [TESTBUG] runtime/appcds/jvmti/ClassFileLoadHookTest.java failed: must be shared
Summary: improve the -Xshare:auto case
Reviewed-by: iklam, coleenp
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java Tue May 28 10:20:05 2019 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java Tue May 28 09:40:49 2019 -0700
@@ -94,10 +94,26 @@
Class c = Class.forName("java.sql.SQLException"); // defined by platform class loader.
switch (testCase) {
- case SHARING_ON_CFLH_OFF:
- case SHARING_AUTO_CFLH_ON:
- case SHARING_ON_CFLH_ON:
- assertTrue(wb.isSharedClass(c), "must be shared");
+ case SHARING_ON_CFLH_OFF:
+ case SHARING_ON_CFLH_ON:
+ assertTrue(wb.isSharedClass(c), "must be shared");
+ break;
+ case SHARING_AUTO_CFLH_ON:
+ // With -Xshare:auto, the test continues to run with mapping failure.
+ // In case of mapping failure, java/lang/Object and the app class
+ // won't be loaded from the archive.
+ Class objClass = Class.forName("java.lang.Object");
+ if (wb.isSharedClass(objClass)) {
+ assertTrue(wb.isSharedClass(c), "must be shared");
+ } else {
+ assertFalse(wb.isSharedClass(c), "must not be shared");
+ }
+ break;
+ default:
+ // this test is not applicable to -Xshare:off
+ if (testCase != TestCaseId.SHARING_OFF_CFLH_ON) {
+ throw new RuntimeException("Invalid testcase");
+ }
}
}
--- a/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java Tue May 28 10:20:05 2019 -0400
+++ b/test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java Tue May 28 09:40:49 2019 -0700
@@ -32,7 +32,6 @@
*/
-import jdk.test.lib.Asserts;
import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;