8224548: [TESTBUG] runtime/appcds/jvmti/ClassFileLoadHookTest.java failed: must be shared

Improve the -Xshare:auto case

Reviewed-by: iklam, coleenp
This commit is contained in:
Calvin Cheung 2019-05-28 09:40:49 -07:00
parent e4325bfd90
commit 421c364797
2 changed files with 20 additions and 5 deletions

View File

@ -95,9 +95,25 @@ public class ClassFileLoadHook {
switch (testCase) {
case SHARING_ON_CFLH_OFF:
case SHARING_AUTO_CFLH_ON:
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");
}
}
}

View File

@ -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;