10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test TestMaxNewSize 26 * @key gc 27 * @bug 7057939 28 * @summary Make sure that MaxNewSize always has a useful value after argument 29 * processing. 30 * @library /testlibrary 31 * @modules java.base/jdk.internal.misc 32 * java.management 33 * @build TestMaxNewSize 34 * @run main TestMaxNewSize -XX:+UseSerialGC 35 * @run main TestMaxNewSize -XX:+UseParallelGC 36 * @run main TestMaxNewSize -XX:+UseConcMarkSweepGC 37 * @run main TestMaxNewSize -XX:+UseG1GC 38 * @author thomas.schatzl@oracle.com, jesper.wilhelmsson@oracle.com 39 */ 40 41 import java.util.regex.Matcher; 42 import java.util.regex.Pattern; 43 44 import java.math.BigInteger; 45 46 import java.util.ArrayList; 47 import java.util.Arrays; 48 49 import jdk.test.lib.*; 50 51 public class TestMaxNewSize { 52 53 private static void checkMaxNewSize(String[] flags, int heapsize) throws Exception { 54 BigInteger actual = new BigInteger(getMaxNewSize(flags)); 55 System.out.println(actual); 56 if (actual.compareTo(new BigInteger((new Long(heapsize)).toString())) == 1) { 57 throw new RuntimeException("MaxNewSize value set to \"" + actual + 58 "\", expected otherwise when running with the following flags: " + Arrays.asList(flags).toString()); 59 } 60 } 61 62 private static void checkIncompatibleNewSize(String[] flags) throws Exception { 63 ArrayList<String> finalargs = new ArrayList<String>(); 64 finalargs.addAll(Arrays.asList(flags)); 65 finalargs.add("-version"); 66 67 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0])); 68 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 69 output.shouldContain("Initial young gen size set larger than the maximum young gen size"); | 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test TestMaxNewSize 26 * @key gc 27 * @bug 7057939 28 * @summary Make sure that MaxNewSize always has a useful value after argument 29 * processing. 30 * @library /test/lib 31 * @modules java.base/jdk.internal.misc 32 * java.management 33 * @run main TestMaxNewSize -XX:+UseSerialGC 34 * @run main TestMaxNewSize -XX:+UseParallelGC 35 * @run main TestMaxNewSize -XX:+UseConcMarkSweepGC 36 * @run main TestMaxNewSize -XX:+UseG1GC 37 * @author thomas.schatzl@oracle.com, jesper.wilhelmsson@oracle.com 38 */ 39 40 import java.util.regex.Matcher; 41 import java.util.regex.Pattern; 42 43 import java.math.BigInteger; 44 45 import java.util.ArrayList; 46 import java.util.Arrays; 47 48 import jdk.test.lib.process.OutputAnalyzer; 49 import jdk.test.lib.process.ProcessTools; 50 51 public class TestMaxNewSize { 52 53 private static void checkMaxNewSize(String[] flags, int heapsize) throws Exception { 54 BigInteger actual = new BigInteger(getMaxNewSize(flags)); 55 System.out.println(actual); 56 if (actual.compareTo(new BigInteger((new Long(heapsize)).toString())) == 1) { 57 throw new RuntimeException("MaxNewSize value set to \"" + actual + 58 "\", expected otherwise when running with the following flags: " + Arrays.asList(flags).toString()); 59 } 60 } 61 62 private static void checkIncompatibleNewSize(String[] flags) throws Exception { 63 ArrayList<String> finalargs = new ArrayList<String>(); 64 finalargs.addAll(Arrays.asList(flags)); 65 finalargs.add("-version"); 66 67 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0])); 68 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 69 output.shouldContain("Initial young gen size set larger than the maximum young gen size"); |