/* * Copyright (c) 2014, 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * @test * @bug 8061611 * @summary Test that various options are deprecated. * @library /testlibrary */ import java.util.ArrayList; import com.oracle.java.testlibrary.*; public class GCDeprecatedOptions8061611 { /** * each entry is {[0]: option name, [1]: value to set * (+/-/n)}. n can be any valid value for the option. */ public static final String[][] DEPRECATED_OPTIONS = { {"CMSMarkStackSizeMax", "1032"}, {"CMSMarkStackSize", "1032"}, {"G1MarkStackSize", "1032"}, {"ParallelMarkingThreads", "77"}, {"ParallelCMSThreads", "77"} }; /** * Turn the option and value into a legal -XX: command line argument. * For example,"-XX:ParallelCMSThreads=77" */ static String makeOptionArg(String option, String value) { if (value.equals("+")) { return "-XX:+" + option; } else if (value.equals("-")) { return "-XX:-" + option; } else { return "-XX:" + option + "=" + value; } } static void testDeprecated(String[][] optionInfo, boolean normalTest) throws Throwable { ArrayList args = new ArrayList<>(); // construct args: for (String[] deprecated: optionInfo) { args.add(makeOptionArg(deprecated[0], deprecated[1])); } args.add("-version"); // start vm: String[] args_array = new String[args.size()]; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(args_array)); OutputAnalyzer output = new OutputAnalyzer(pb.start()); // check for option deprecation messages: output.shouldHaveExitValue(0); for (String[] deprecated: optionInfo) { // Searching precisely for deprecation warnings is too hard at the moment. // There is no standard format. For now, just search for the option name in the output, // which should only be printed if there was some deprecation warning. String realOpt = (deprecated.length == 2) ? deprecated[0] : deprecated[1]; String match = realOpt; if (normalTest) { output.shouldMatch(match); } else { output.shouldNotMatch(match); } } } public static void main(String[] args) throws Throwable { // test the test: String[][] testTestDeprecated = {{"UseTLAB", "+"}}; testDeprecated(testTestDeprecated, false); // Test the test. The output should NOT mention "UseTLAB" at all. // run real test: testDeprecated(DEPRECATED_OPTIONS, true); // Make sure that each deprecated option is mentioned in the output. } }