< prev index next >

test/runtime/CommandLine/OptionsValidation/common/optionsvalidation/JVMOptionsUtils.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2015, 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 25,34 **** --- 25,36 ---- import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; + import java.lang.management.GarbageCollectorMXBean; + import java.lang.management.ManagementFactory; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.LinkedHashMap;
*** 48,57 **** --- 50,62 ---- private static final StringBuilder finalFailedMessage = new StringBuilder(); /* Used to start the JVM with the same type as current */ static String VMType; + /* Used to start the JVM with the same GC type as current */ + static String GCType; + private static Map<String, JVMOption> optionsAsMap; static { if (Platform.isServer()) { VMType = "-server";
*** 62,71 **** --- 67,97 ---- } else if (Platform.isGraal()) { VMType = "-graal"; } else { VMType = null; } + + List<GarbageCollectorMXBean> gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans(); + + GCType = null; + + for (GarbageCollectorMXBean gcMxBean : gcMxBeans) { + switch (gcMxBean.getName()) { + case "ConcurrentMarkSweep": + GCType = "-XX:+UseConcMarkSweepGC"; + break; + case "MarkSweepCompact": + GCType = "-XX:+UseSerialGC"; + break; + case "PS Scavenge": + GCType = "-XX:+UseParallelGC"; + break; + case "G1 Old Generation": + GCType = "-XX:+UseG1GC"; + break; + } + } } public static boolean fitsRange(String optionName, BigDecimal number) throws Exception { JVMOption option; String minRangeString = null;
*** 151,168 **** * @param option option */ private static void addNameDependency(JVMOption option) { String name = option.getName(); - if (name.startsWith("G1")) { - option.addPrepend("-XX:+UseG1GC"); - } - - if (name.startsWith("CMS")) { - option.addPrepend("-XX:+UseConcMarkSweepGC"); - } - if (name.startsWith("NUMA")) { option.addPrepend("-XX:+UseNUMA"); } switch (name) { --- 177,186 ----
*** 441,450 **** --- 459,472 ---- } if (VMType != null) { runJava.add(VMType); } + + if (GCType != null) { + runJava.add(GCType); + } runJava.add(PRINT_FLAGS_RANGES); runJava.add("-version"); p = ProcessTools.createJavaProcessBuilder(runJava.toArray(new String[0])).start();
*** 532,542 **** * occurred while reading the data */ public static Map<String, JVMOption> getOptionsWithRangeAsMap(String... additionalArgs) throws Exception { return getOptionsWithRangeAsMap(origin -> true, additionalArgs); } - - /* Simple method to test that java start-up. Used for testing options. */ - public static void main(String[] args) { - System.out.print("Java start-up!"); - } } --- 554,559 ----
< prev index next >