8224548: [TESTBUG] runtime/appcds/jvmti/ClassFileLoadHookTest.java failed: must be shared
authorccheung
Tue, 28 May 2019 09:40:49 -0700
changeset 55060 b5ca5b98037b
parent 55059 0422b4b5cb8e
child 55061 d1fa0f8d8c9a
8224548: [TESTBUG] runtime/appcds/jvmti/ClassFileLoadHookTest.java failed: must be shared Summary: improve the -Xshare:auto case Reviewed-by: iklam, coleenp
test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHook.java
test/hotspot/jtreg/runtime/appcds/jvmti/ClassFileLoadHookTest.java
--- 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;