From a88be1c90aeec6a3a7f6154234f06544fad5f2da Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Thu, 16 May 2024 19:54:57 +0000 Subject: [PATCH 1/6] 8330647: Two CDS tests fail with -UseCompressedOops and UseSerialGC/UseParallelGC --- .../runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java | 1 + .../cds/serviceability/ReplaceCriticalClassesForSubgraphs.java | 1 + 2 files changed, 2 insertions(+) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java index f597556944797..bd78a5d2c8433 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java @@ -27,6 +27,7 @@ * @bug 8214781 8293187 * @summary Test for the -XX:ArchiveHeapTestClass flag * @requires vm.debug == true & vm.cds.write.archived.java.heap + * @requires vm.gc == null * @modules java.base/sun.invoke.util java.logging * @library /test/jdk/lib/testlibrary /test/lib * /test/hotspot/jtreg/runtime/cds/appcds diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java index 71d984d3a638c..868c5d6e785ee 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java @@ -28,6 +28,7 @@ * @library /test/lib * @requires vm.cds.write.archived.java.heap * @requires !vm.jvmci.enabled + * @requires vm.gc == null * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox * @run main/othervm/native ReplaceCriticalClassesForSubgraphs From 51891a02e543fe324baff86b12b4711cd932cdd3 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Thu, 16 May 2024 21:39:28 +0000 Subject: [PATCH 2/6] check the test.cds.runtime.options property --- .../cds/appcds/cacheObject/ArchiveHeapTestClass.java | 7 ++++++- .../serviceability/ReplaceCriticalClassesForSubgraphs.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java index bd78a5d2c8433..76dbe650b95c7 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java @@ -27,7 +27,6 @@ * @bug 8214781 8293187 * @summary Test for the -XX:ArchiveHeapTestClass flag * @requires vm.debug == true & vm.cds.write.archived.java.heap - * @requires vm.gc == null * @modules java.base/sun.invoke.util java.logging * @library /test/jdk/lib/testlibrary /test/lib * /test/hotspot/jtreg/runtime/cds/appcds @@ -46,6 +45,8 @@ import jdk.test.lib.helpers.ClassFileInstaller; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; + public class ArchiveHeapTestClass { static final String bootJar = ClassFileInstaller.getJarPath("boot.jar"); static final String appJar = ClassFileInstaller.getJarPath("app.jar"); @@ -62,6 +63,10 @@ public class ArchiveHeapTestClass { static final String ARCHIVE_TEST_FIELD_NAME = "archivedObjects"; public static void main(String[] args) throws Exception { + if (System.getProperty("test.cds.runtime.options") != null) { + throw new SkippedException( + "options specified via the test.cds.runtime.options property may not be compatible with this test"); + } testDebugBuild(); } diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java index 868c5d6e785ee..43d089f98670a 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java @@ -28,14 +28,19 @@ * @library /test/lib * @requires vm.cds.write.archived.java.heap * @requires !vm.jvmci.enabled - * @requires vm.gc == null * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar whitebox.jar jdk.test.whitebox.WhiteBox * @run main/othervm/native ReplaceCriticalClassesForSubgraphs */ +import jtreg.SkippedException; + public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses { public static void main(String args[]) throws Throwable { + if (System.getProperty("test.cds.runtime.options") != null) { + throw new SkippedException( + "options specified via the test.cds.runtime.options property may not be compatible with this test"); + } ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs(); rcc.process(args); } From 83529521a009945d83b38a9e61e1b81d3650b0e3 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 17 May 2024 16:30:58 +0000 Subject: [PATCH 3/6] check test.cds.runtime.options property in VMProps.java --- .../cacheObject/ArchiveHeapTestClass.java | 6 ---- .../ReplaceCriticalClassesForSubgraphs.java | 6 ---- test/jtreg-ext/requires/VMProps.java | 28 +++++++++++++++++-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java index 76dbe650b95c7..f597556944797 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchiveHeapTestClass.java @@ -45,8 +45,6 @@ import jdk.test.lib.helpers.ClassFileInstaller; import jdk.test.lib.process.OutputAnalyzer; -import jtreg.SkippedException; - public class ArchiveHeapTestClass { static final String bootJar = ClassFileInstaller.getJarPath("boot.jar"); static final String appJar = ClassFileInstaller.getJarPath("app.jar"); @@ -63,10 +61,6 @@ public class ArchiveHeapTestClass { static final String ARCHIVE_TEST_FIELD_NAME = "archivedObjects"; public static void main(String[] args) throws Exception { - if (System.getProperty("test.cds.runtime.options") != null) { - throw new SkippedException( - "options specified via the test.cds.runtime.options property may not be compatible with this test"); - } testDebugBuild(); } diff --git a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java index 43d089f98670a..71d984d3a638c 100644 --- a/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java +++ b/test/hotspot/jtreg/runtime/cds/serviceability/ReplaceCriticalClassesForSubgraphs.java @@ -33,14 +33,8 @@ * @run main/othervm/native ReplaceCriticalClassesForSubgraphs */ -import jtreg.SkippedException; - public class ReplaceCriticalClassesForSubgraphs extends ReplaceCriticalClasses { public static void main(String args[]) throws Throwable { - if (System.getProperty("test.cds.runtime.options") != null) { - throw new SkippedException( - "options specified via the test.cds.runtime.options property may not be compatible with this test"); - } ReplaceCriticalClassesForSubgraphs rcc = new ReplaceCriticalClassesForSubgraphs(); rcc.process(args); } diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index b55063f04f2c8..78f517ec97681 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -333,6 +333,8 @@ protected void vmGC(SafeMap map) { map.put("vm.gc.ZSinglegen", () -> "" + (vmGCZ && (!genZ || genZIsDefault))); } + final String GC_PREFIX = "-XX:+Use"; + final String GC_SUFFIX = "GC"; /** * "jtreg -vmoptions:-Dtest.cds.runtime.options=..." can be used to specify * the GC type to be used when running with a CDS archive. Set "vm.gc" accordingly, @@ -348,8 +350,6 @@ protected void vmGCforCDS(SafeMap map) { return; } - String GC_PREFIX = "-XX:+Use"; - String GC_SUFFIX = "GC"; String jtropts = System.getProperty("test.cds.runtime.options"); if (jtropts != null) { for (String opt : jtropts.split(",")) { @@ -462,7 +462,29 @@ protected String vmCDSForCustomLoaders() { * @return true if this VM can write Java heap objects into the CDS archive */ protected String vmCDSCanWriteArchivedJavaHeap() { - return "" + ("true".equals(vmCDS()) && WB.canWriteJavaHeapArchive()); + return "" + ("true".equals(vmCDS()) && WB.canWriteJavaHeapArchive() + && isCDSRuntimeOptionsCompatible()); + } + + /** + * @return true if the VM options specified via the "test.cds.runtime.options" + * property is compatible with writing Java heap objects into the CDS archive + */ + protected boolean isCDSRuntimeOptionsCompatible() { + String jtropts = System.getProperty("test.cds.runtime.options"); + if (jtropts == null) + return true; + String CCP_DISABLED = "-XX:-UseCompressedClassPointers"; + for (String opt : jtropts.split(",")) { + if (opt.equals(CCP_DISABLED)) + return false; + if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX)) { + String gc = opt.substring(GC_PREFIX.length(), opt.length() - GC_SUFFIX.length()); + if (!gc.equals("G1")) + return false; + } + } + return true; } /** From 23d69b0d27bd09219fb43a2dd930123c66d9e8c0 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Tue, 21 May 2024 20:51:13 +0000 Subject: [PATCH 4/6] comments from David H. and @turbanoff --- test/jtreg-ext/requires/VMProps.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 78f517ec97681..e5b09f8aec3ef 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -333,8 +333,8 @@ protected void vmGC(SafeMap map) { map.put("vm.gc.ZSinglegen", () -> "" + (vmGCZ && (!genZ || genZIsDefault))); } - final String GC_PREFIX = "-XX:+Use"; - final String GC_SUFFIX = "GC"; + final String GC_PREFIX = "-XX:+Use"; + final String GC_SUFFIX = "GC"; /** * "jtreg -vmoptions:-Dtest.cds.runtime.options=..." can be used to specify * the GC type to be used when running with a CDS archive. Set "vm.gc" accordingly, @@ -475,14 +475,13 @@ protected boolean isCDSRuntimeOptionsCompatible() { if (jtropts == null) return true; String CCP_DISABLED = "-XX:-UseCompressedClassPointers"; + String G1GC_ENABLED = "-XX:+UseG1GC"; for (String opt : jtropts.split(",")) { if (opt.equals(CCP_DISABLED)) return false; - if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX)) { - String gc = opt.substring(GC_PREFIX.length(), opt.length() - GC_SUFFIX.length()); - if (!gc.equals("G1")) - return false; - } + if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX) && + !opt.equals(G1GC_ENABLED)) + return false; } return true; } From 1c0ef09a60df81f391d89b400c3eac6002786cda Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Wed, 22 May 2024 15:59:09 +0000 Subject: [PATCH 5/6] @stefank comments --- test/jtreg-ext/requires/VMProps.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index e5b09f8aec3ef..9b2e72c3e7555 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -67,6 +67,9 @@ public class VMProps implements Callable> { // value known to jtreg as an indicator of error state private static final String ERROR_STATE = "__ERROR__"; + private static final String GC_PREFIX = "-XX:+Use"; + private static final String GC_SUFFIX = "GC"; + private static final WhiteBox WB = WhiteBox.getWhiteBox(); private static class SafeMap { @@ -333,8 +336,6 @@ protected void vmGC(SafeMap map) { map.put("vm.gc.ZSinglegen", () -> "" + (vmGCZ && (!genZ || genZIsDefault))); } - final String GC_PREFIX = "-XX:+Use"; - final String GC_SUFFIX = "GC"; /** * "jtreg -vmoptions:-Dtest.cds.runtime.options=..." can be used to specify * the GC type to be used when running with a CDS archive. Set "vm.gc" accordingly, @@ -477,11 +478,13 @@ protected boolean isCDSRuntimeOptionsCompatible() { String CCP_DISABLED = "-XX:-UseCompressedClassPointers"; String G1GC_ENABLED = "-XX:+UseG1GC"; for (String opt : jtropts.split(",")) { - if (opt.equals(CCP_DISABLED)) + if (opt.equals(CCP_DISABLED)) { return false; + } if (opt.startsWith(GC_PREFIX) && opt.endsWith(GC_SUFFIX) && - !opt.equals(G1GC_ENABLED)) + !opt.equals(G1GC_ENABLED)) { return false; + } } return true; } From 174108767442f8a86348686d49b5cd11083555c7 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Thu, 23 May 2024 20:44:26 +0000 Subject: [PATCH 6/6] add missing braces --- test/jtreg-ext/requires/VMProps.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 9b2e72c3e7555..e37646ac6d1c5 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -473,8 +473,9 @@ protected String vmCDSCanWriteArchivedJavaHeap() { */ protected boolean isCDSRuntimeOptionsCompatible() { String jtropts = System.getProperty("test.cds.runtime.options"); - if (jtropts == null) + if (jtropts == null) { return true; + } String CCP_DISABLED = "-XX:-UseCompressedClassPointers"; String G1GC_ENABLED = "-XX:+UseG1GC"; for (String opt : jtropts.split(",")) {