From 81e0c87f28934cb0d66ad2500352b2728f44a1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20H=C3=BCbner?= Date: Fri, 14 Nov 2025 08:29:57 +0000 Subject: [PATCH] 8371320: runtime/ErrorHandling/PrintVMInfoAtExitTest.java fails with unexpected amount for Java Heap reserved memory Reviewed-by: azafari, jsikstro --- .../ErrorHandling/PrintVMInfoAtExitTest.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/PrintVMInfoAtExitTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/PrintVMInfoAtExitTest.java index 5e535bab626..80c209a9ec4 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/PrintVMInfoAtExitTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/PrintVMInfoAtExitTest.java @@ -27,17 +27,13 @@ * @test * @summary Test PrintVMInfoAtExit * @library /test/lib - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @modules java.base/jdk.internal.misc * @requires vm.flagless * @requires vm.bits == "64" - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI PrintVMInfoAtExitTest + * @run driver PrintVMInfoAtExitTest */ import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import jdk.test.whitebox.WhiteBox; public class PrintVMInfoAtExitTest { @@ -52,18 +48,20 @@ public class PrintVMInfoAtExitTest { "-XX:CompressedClassSpaceSize=256m", "-version"); + // How many kb of committed memory we expect in the NMT summary. + int committed_kb = 65536; OutputAnalyzer output_detail = new OutputAnalyzer(pb.start()); output_detail.shouldContain("# JRE version:"); output_detail.shouldContain("-- S U M M A R Y --"); output_detail.shouldContain("Command Line: -Xmx64M -Xms64M -XX:-CreateCoredumpOnCrash -XX:+UnlockDiagnosticVMOptions -XX:+PrintVMInfoAtExit -XX:NativeMemoryTracking=summary -XX:CompressedClassSpaceSize=256m"); output_detail.shouldContain("Native Memory Tracking:"); - WhiteBox wb = WhiteBox.getWhiteBox(); - if (wb.isAsanEnabled()) { - // the reserved value can be influenced by asan - output_detail.shouldContain("Java Heap (reserved="); - output_detail.shouldContain(", committed=65536KB)"); - } else { - output_detail.shouldContain("Java Heap (reserved=65536KB, committed=65536KB)"); + // Make sure the heap summary is present. + output_detail.shouldMatch("Java Heap \\(reserved=[0-9]+KB, committed=" + committed_kb + "KB\\)"); + // Check reserved >= committed. + String reserved_kb_string = output_detail.firstMatch("Java Heap \\(reserved=([0-9]+)KB, committed=" + committed_kb + "KB\\)", 1); + int reserved_kb = Integer.parseInt(reserved_kb_string); + if (reserved_kb < committed_kb) { + throw new RuntimeException("committed more memory than reserved"); } } }