diff a/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java b/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java --- a/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/DumpingWithNoCoops.java @@ -70,20 +70,39 @@ static HeapArgs[] heapArgsCases = { // InitialHeapSize, MinHeapSize, MaxHeapSize // all sizes are in the unit of GB // size of 0 means don't set the heap size new HeapArgs( 0, 0, 0), - new HeapArgs( 8, 0, 0), - new HeapArgs( 0, 8, 0), - new HeapArgs( 0, 0, 8), - new HeapArgs( 8, 8, 0), - new HeapArgs( 0, 8, 8), - new HeapArgs( 8, 0, 8), - new HeapArgs( 8, 8, 8), + new HeapArgs( 5, 3, 5), + new HeapArgs( 3, 5, 5), + new HeapArgs( 3, 3, 5), + new HeapArgs( 5, 5, 5), new HeapArgs( 2, 1, 33), }; + static void checkExpectedMessages(HeapArgs ha, OutputAnalyzer output) throws Exception { + final int DUMPTIME_MAX_HEAP = 4; // 4 GB + if (ha.minSize > DUMPTIME_MAX_HEAP) { + output.shouldContain("Setting MinHeapSize to 4G for CDS dumping"); + } + if (ha.initialSize > DUMPTIME_MAX_HEAP) { + output.shouldContain("Setting InitialHeapSize to 4G for CDS dumping"); + } + if (ha.maxSize > DUMPTIME_MAX_HEAP) { + output.shouldContain("Setting MaxHeapSize to 4G for CDS dumping"); + } + } + + static boolean heapSizesCompatible(String stdout) { + if (stdout.contains("Initial heap size set to a larger value than the maximum heap size") || + stdout.contains("Incompatible minimum and initial heap sizes specified") || + stdout.contains("Incompatible minimum and maximum heap sizes specified")) { + return false; + } + return true; + } + public static void main(String[] args) throws Exception { final String noCoops = "-XX:-UseCompressedOops"; final String logArg = "-Xlog:gc+heap=trace,cds=debug"; JarBuilder.getOrCreateHelloJar(); String appJar = TestCommon.getTestJar("hello.jar"); @@ -106,15 +125,28 @@ String[] heapSizes = heapArg.split(" "); for (String heapSize : heapSizes) { dumptimeArgs.add(heapSize); } output = TestCommon.dump(appJar, appClasses, dumptimeArgs.toArray(new String[0])); - output.shouldContain("Setting MaxHeapSize to 4G for CDS dumping"); + checkExpectedMessages(ha, output); } - TestCommon.checkDump(output); - TestCommon.run("-cp", appJar, - logArg, "-Xlog:class+load", noCoops, "Hello") - .assertNormalExit("Hello source: shared objects file"); + boolean shouldProceed = true; + try { + TestCommon.checkDump(output); + } catch (java.lang.RuntimeException ex) { + String stdout = output.getStdout(); + if (!heapSizesCompatible(stdout)) { + System.out.println("Specified heap sizes are incompatible, dumping has failed."); + shouldProceed = false; + } else { + throw(ex); + } + } + if (shouldProceed) { + TestCommon.run("-cp", appJar, + logArg, "-Xlog:class+load", noCoops, "Hello") + .assertNormalExit("Hello source: shared objects file"); + } } } }