From bb2cdfe5692db91a3e7ca997ab46f3783f69d7f5 Mon Sep 17 00:00:00 2001 From: Ashutosh Mehra Date: Fri, 24 Jul 2026 18:09:00 +0000 Subject: [PATCH] 8387743: [aot] AOT tests fail intermittently with "incompatible CompressedOops::base()" Reviewed-by: kvn, iklam --- .../aotCode/AOTCodeCompressedOopsTest.java | 3 + .../runtime/cds/appcds/aotFlags/AOTFlags.java | 4 + test/lib/jdk/test/lib/cds/CDSAppTester.java | 132 ++++++++++-------- 3 files changed, 81 insertions(+), 58 deletions(-) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java index aea4f7e9f8f..29b0f59b238 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java @@ -125,7 +125,10 @@ public class AOTCodeCompressedOopsTest { switch (runMode) { case RunMode.ASSEMBLY: { List args = getVMArgsForHeapConfig(zeroBaseInAsmPhase, zeroShiftInAsmPhase); + // By default CDSAppTester adds -XX:+AOTCompatibleOopCompression option, + // which defeats the purpose of this test. So disable this option. args.addAll(List.of("-XX:+UnlockDiagnosticVMOptions", + "-XX:-AOTCompatibleOopCompression", "-Xlog:aot=info", "-Xlog:aot+codecache+init=debug", "-Xlog:aot+codecache+exit=debug")); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotFlags/AOTFlags.java b/test/hotspot/jtreg/runtime/cds/appcds/aotFlags/AOTFlags.java index dcb2b595243..56c31dcdbda 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotFlags/AOTFlags.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotFlags/AOTFlags.java @@ -72,6 +72,8 @@ public class AOTFlags { "-XX:AOTConfiguration=" + aotConfigFile, "-XX:AOTCache=" + aotCacheFile, "-Xlog:aot", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+AOTCompatibleOopCompression", // avoid production run failure due to incompatible CompressedOops::base "-cp", appJar); out = CDSTestUtils.executeAndLog(pb, "asm"); out.shouldContain("AOTCache creation is complete"); @@ -142,6 +144,8 @@ public class AOTFlags { "-XX:AOTConfiguration=" + aotConfigFile, "-XX:AOTCache=" + aotCacheFile, "-Xlog:aot", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+AOTCompatibleOopCompression", // avoid production run failure due to incompatible CompressedOops::base "-cp", appJar); out = CDSTestUtils.executeAndLog(pb, "asm"); out.shouldContain("AOTCache creation is complete"); diff --git a/test/lib/jdk/test/lib/cds/CDSAppTester.java b/test/lib/jdk/test/lib/cds/CDSAppTester.java index 80ff54021f5..0be21b9ec27 100644 --- a/test/lib/jdk/test/lib/cds/CDSAppTester.java +++ b/test/lib/jdk/test/lib/cds/CDSAppTester.java @@ -228,9 +228,18 @@ abstract public class CDSAppTester { return output; } - private String[] addCommonVMArgs(RunMode runMode, String[] cmdLine) { + // This method should be called before `vmArgs()`, so that subclasses of CDSAppTester + // can have a chance to override the flags set here. + private String[] addCommonVMArgs(RunMode runMode) { + String[] cmdLine = new String[0]; cmdLine = addClassOrModulePath(runMode, cmdLine); cmdLine = addWhiteBox(cmdLine); + // In one-step workflow ASSEMBLY phase is not executed separately. + // Therefore AOTCompatibleOopCompression needs to be passed to the TRAINING phase, + // so that it can be propagated to the ASSEMBLY phase. + if (runMode == RunMode.TRAINING || runMode == RunMode.ASSEMBLY) { + cmdLine = StringArrayUtils.concat(cmdLine, "-XX:+UnlockDiagnosticVMOptions", "-XX:+AOTCompatibleOopCompression"); + } return cmdLine; } @@ -261,30 +270,32 @@ abstract public class CDSAppTester { private OutputAnalyzer recordAOTConfiguration() throws Exception { RunMode runMode = RunMode.TRAINING; - String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), - "-XX:AOTMode=record", - "-XX:AOTConfiguration=" + aotConfigurationFile, - logToFile(aotConfigurationFileLog, - "class+load=debug", - "aot=debug", - "cds=debug", - "aot+class=debug")); - cmdLine = addCommonVMArgs(runMode, cmdLine); + String[] cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, + "-XX:AOTMode=record", + "-XX:AOTConfiguration=" + aotConfigurationFile, + logToFile(aotConfigurationFileLog, + "class+load=debug", + "aot=debug", + "cds=debug", + "aot+class=debug")); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); return executeAndCheck(cmdLine, runMode, aotConfigurationFile, aotConfigurationFileLog); } private OutputAnalyzer createAOTCacheOneStep() throws Exception { RunMode runMode = RunMode.TRAINING; - String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), - "-XX:AOTMode=record", - "-XX:AOTCacheOutput=" + aotCacheFile, - logToFile(aotCacheFileLog, - "class+load=debug", - "aot=debug", - "aot+class=debug", - "cds=debug")); - cmdLine = addCommonVMArgs(runMode, cmdLine); + String[] cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, + "-XX:AOTMode=record", + "-XX:AOTCacheOutput=" + aotCacheFile, + logToFile(aotCacheFileLog, + "class+load=debug", + "aot=debug", + "aot+class=debug", + "cds=debug")); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); OutputAnalyzer out = executeAndCheck(cmdLine, runMode, aotCacheFile, aotCacheFileLog); listOutputFile(aotCacheFileLog + ".0"); // the log file for the training run @@ -293,52 +304,55 @@ abstract public class CDSAppTester { private OutputAnalyzer createClassList() throws Exception { RunMode runMode = RunMode.TRAINING; - String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), - "-Xshare:off", - "-XX:DumpLoadedClassList=" + classListFile, - logToFile(classListFileLog, - "class+load=debug")); - cmdLine = addCommonVMArgs(runMode, cmdLine); + String[] cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, + "-Xshare:off", + "-XX:DumpLoadedClassList=" + classListFile, + logToFile(classListFileLog, + "class+load=debug")); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); return executeAndCheck(cmdLine, runMode, classListFile, classListFileLog); } private OutputAnalyzer dumpStaticArchive() throws Exception { RunMode runMode = RunMode.DUMP_STATIC; - String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), - "-Xlog:aot", - "-Xlog:aot+heap=error", - "-Xlog:cds", - "-Xshare:dump", - "-XX:SharedArchiveFile=" + staticArchiveFile, - "-XX:SharedClassListFile=" + classListFile, - logToFile(staticArchiveFileLog, - "aot=debug", - "cds=debug", - "cds+class=debug", - "aot+heap=warning", - "aot+resolve=debug")); - cmdLine = addCommonVMArgs(runMode, cmdLine); + String[] cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, + "-Xlog:aot", + "-Xlog:aot+heap=error", + "-Xlog:cds", + "-Xshare:dump", + "-XX:SharedArchiveFile=" + staticArchiveFile, + "-XX:SharedClassListFile=" + classListFile, + logToFile(staticArchiveFileLog, + "aot=debug", + "cds=debug", + "cds+class=debug", + "aot+heap=warning", + "aot+resolve=debug")); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); return executeAndCheck(cmdLine, runMode, staticArchiveFile, staticArchiveFileLog); } private OutputAnalyzer createAOTCache() throws Exception { RunMode runMode = RunMode.ASSEMBLY; - String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), - "-Xlog:aot", - "-Xlog:aot+heap=error", - "-Xlog:cds", - "-XX:AOTMode=create", - "-XX:AOTConfiguration=" + aotConfigurationFile, - "-XX:AOTCache=" + aotCacheFile, - logToFile(aotCacheFileLog, - "cds=debug", - "aot=debug", - "aot+class=debug", - "aot+heap=warning", - "aot+resolve=debug")); - cmdLine = addCommonVMArgs(runMode, cmdLine); + String[] cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, + "-Xlog:aot", + "-Xlog:aot+heap=error", + "-Xlog:cds", + "-XX:AOTMode=create", + "-XX:AOTConfiguration=" + aotConfigurationFile, + "-XX:AOTCache=" + aotCacheFile, + logToFile(aotCacheFileLog, + "cds=debug", + "aot=debug", + "aot+class=debug", + "aot+heap=warning", + "aot+resolve=debug")); cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode)); return executeAndCheck(cmdLine, runMode, aotCacheFile, aotCacheFileLog); } @@ -387,7 +401,9 @@ abstract public class CDSAppTester { String baseArchive = getBaseArchiveForDynamicArchive(); if (isDynamicWorkflow()) { // "classic" dynamic archive - cmdLine = StringArrayUtils.concat(vmArgs(runMode), + cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, "-Xlog:aot", "-Xlog:cds", "-XX:ArchiveClassesAtExit=" + dynamicArchiveFile, @@ -397,7 +413,6 @@ abstract public class CDSAppTester { "cds+class=debug", "aot+resolve=debug", "class+load=debug")); - cmdLine = addCommonVMArgs(runMode, cmdLine); } if (baseArchive != null) { cmdLine = StringArrayUtils.concat(cmdLine, "-XX:SharedArchiveFile=" + baseArchive); @@ -418,9 +433,10 @@ abstract public class CDSAppTester { // using different args to the VM and application. public OutputAnalyzer productionRun(String[] extraVmArgs, String[] extraAppArgs) throws Exception { RunMode runMode = RunMode.PRODUCTION; - String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode), - logToFile(productionRunLog(), "aot", "cds")); - cmdLine = addCommonVMArgs(runMode, cmdLine); + String[] cmdLine = addCommonVMArgs(runMode); + cmdLine = StringArrayUtils.concat(cmdLine, vmArgs(runMode)); + cmdLine = StringArrayUtils.concat(cmdLine, + logToFile(productionRunLog(), "aot", "cds")); if (isStaticWorkflow()) { cmdLine = StringArrayUtils.concat(cmdLine, "-Xshare:on", "-XX:SharedArchiveFile=" + staticArchiveFile);