diff --git a/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java b/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java index 03376308e3932..6abcc9f84fe86 100644 --- a/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java +++ b/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,8 @@ * @bug 7057939 * @summary Make sure that MaxNewSize always has a useful value after argument * processing. - * @requires vm.gc.Serial + * @key flag-sensitive + * @requires vm.gc.Serial & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null & vm.opt.x.Xms == null & vm.opt.x.Xmx == null * @library /test/lib * @library / * @modules java.base/jdk.internal.misc @@ -42,7 +43,8 @@ * @bug 7057939 * @summary Make sure that MaxNewSize always has a useful value after argument * processing. - * @requires vm.gc.Parallel + * @key flag-sensitive + * @requires vm.gc.Parallel & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null & vm.opt.x.Xms == null & vm.opt.x.Xmx == null * @library /test/lib * @library / * @modules java.base/jdk.internal.misc @@ -56,7 +58,8 @@ * @bug 7057939 * @summary Make sure that MaxNewSize always has a useful value after argument * processing. - * @requires vm.gc.G1 + * @key flag-sensitive + * @requires vm.gc.G1 & vm.opt.MaxNewSize == null & vm.opt.NewRatio == null & vm.opt.NewSize == null & vm.opt.OldSize == null & vm.opt.x.Xms == null & vm.opt.x.Xmx == null * @library /test/lib * @library / * @modules java.base/jdk.internal.misc @@ -79,46 +82,23 @@ public class TestMaxNewSize { private static void checkMaxNewSize(String[] flags, int heapsize) throws Exception { BigInteger actual = new BigInteger(getMaxNewSize(flags)); - System.out.println(actual); - if (actual.compareTo(new BigInteger((new Long(heapsize)).toString())) == 1) { + System.out.println("asserting: " + actual + " <= " + heapsize); + if (actual.compareTo(new BigInteger("" + heapsize)) > 0) { throw new RuntimeException("MaxNewSize value set to \"" + actual + "\", expected otherwise when running with the following flags: " + Arrays.asList(flags).toString()); } } - private static void checkIncompatibleNewSize(String[] flags) throws Exception { - ArrayList finalargs = new ArrayList(); - finalargs.addAll(Arrays.asList(flags)); - finalargs.add("-version"); - - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Initial young gen size set larger than the maximum young gen size"); - } - - private static boolean isRunningG1(String[] args) { - for (int i = 0; i < args.length; i++) { - if (args[i].contains("+UseG1GC")) { - return true; - } - } - return false; - } - private static String getMaxNewSize(String[] flags) throws Exception { ArrayList finalargs = new ArrayList(); finalargs.addAll(Arrays.asList(flags)); - if (isRunningG1(flags)) { - finalargs.add("-XX:G1HeapRegionSize=1M"); - } finalargs.add("-XX:+PrintFlagsFinal"); finalargs.add("-version"); - ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs); + ProcessBuilder pb = GCArguments.createTestJvm(finalargs); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String stdout = output.getStdout(); - //System.out.println(stdout); return getFlagValue("MaxNewSize", stdout); }