From 2b5fe3a4b38bbdf0d155b2b4907db2416891c2b0 Mon Sep 17 00:00:00 2001 From: tstuefe Date: Mon, 9 Feb 2026 10:05:54 +0100 Subject: [PATCH] David: minimize diffs for runtime/ErrorHandling/TestVMConfigInHsErrFile.java --- .../TestVMConfigInHsErrFile.java | 53 ++++++++++++++----- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java b/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java index d6390ed1394..8f41121fbc1 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/TestVMConfigInHsErrFile.java @@ -30,7 +30,7 @@ * @requires vm.debug * @modules java.base/jdk.internal.misc * java.management - * @run driver TestVMConfigInHsErrFile false + * @run driver TestVMConfigInHsErrFile coh-off */ /* @@ -42,28 +42,29 @@ * @requires vm.debug * @modules java.base/jdk.internal.misc * java.management - * @run driver TestVMConfigInHsErrFile true + * @run driver TestVMConfigInHsErrFile coh-on */ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.io.File; +import java.util.ArrayList; import java.util.regex.Pattern; public class TestVMConfigInHsErrFile { public static void main(String[] args) throws Exception { - test(Boolean.parseBoolean(args[0])); + switch (args[0]) { + case "coh-on" -> testCompactObjectHeaders(); + case "coh-off" -> testNotCompactObjectHeaders(); + } } - private static void test(boolean coh) throws Exception { - final String argument = "-XX:%cUseCompactObjectHeaders".formatted(coh ? '+' : '-'); - final Pattern[] pattern = new Pattern[] { Pattern.compile("# Java VM: .*compact obj headers.*") }; - + private static void testCompactObjectHeaders() throws Exception { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockExperimentalVMOptions", - argument, + "-XX:+UseCompactObjectHeaders", "-Xmx100M", "-XX:-CreateCoredumpOnCrash", "-XX:ErrorHandlerTest=14", @@ -74,10 +75,36 @@ public class TestVMConfigInHsErrFile { // extract hs-err file File f = HsErrFileUtils.openHsErrFileFromOutput(output); - if (coh) { - HsErrFileUtils.checkHsErrFileContent(f, pattern, null, true, true); - } else { - HsErrFileUtils.checkHsErrFileContent(f, null, pattern, true, true); - } + + Pattern[] expectedPatterns = new Pattern[] { + Pattern.compile("# Java VM: .*compact obj headers.*") + }; + + HsErrFileUtils.checkHsErrFileContent(f, expectedPatterns, null, true, true); + + } + + private static void testNotCompactObjectHeaders() throws Exception { + ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+UnlockExperimentalVMOptions", + "-XX:-UseCompactObjectHeaders", + "-Xmx100M", + "-XX:-CreateCoredumpOnCrash", + "-XX:ErrorHandlerTest=14", + "-version"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotHaveExitValue(0); + + // extract hs-err file + File f = HsErrFileUtils.openHsErrFileFromOutput(output); + + Pattern[] notExpectedPatterns = new Pattern[] { + Pattern.compile("# Java VM: .*compact obj headers.*") + }; + + HsErrFileUtils.checkHsErrFileContent(f, null, notExpectedPatterns, true, true); + } }