--- /dev/null 2014-12-13 10:35:39.117184000 -0500 +++ new/test/runtime/CommandLine/VMDeprecatedOptions.java 2015-01-12 17:07:10.311617691 -0500 @@ -0,0 +1,79 @@ +/* + * 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. + * + * 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. + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.cli.CommandLineOptionTest; + +/* + * @test + * @bug 8066821 + * @summary Test that various options are deprecated. See deprecated_jvm_flags in arguments.cpp. + * @library /testlibrary + */ +public class VMDeprecatedOptions { + + /** + * each entry is {[0]: option name, [1]: value to set + * (true/false/n/string)}. + */ + public static final String[][] DEPRECATED_OPTIONS = { + // deprecated non-alias flags: + {"MaxGCMinorPauseMillis", "1032"}, + {"UseParNewGC", "false"}, + + // deprecated alias flags (see also aliased_jvm_flags): + {"DefaultMaxRAMFraction", "4"}, + {"CMSMarkStackSizeMax", "1032"}, + {"CMSMarkStackSize", "1032"}, + {"G1MarkStackSize", "1032"}, + {"ParallelMarkingThreads", "77"}, + {"ParallelCMSThreads", "77"} + }; + + static String getDeprecationString(String optionName) { + return "option " + optionName + + " was deprecated in version [\\S]+ and will likely be removed in a future release"; + } + + static void testDeprecated(String[][] optionInfo) throws Throwable { + String optionNames[] = new String[optionInfo.length]; + String expectedValues[] = new String[optionInfo.length]; + for (int i = 0; i < optionInfo.length; i++) { + optionNames[i] = optionInfo[i][0]; + expectedValues[i] = optionInfo[i][1]; + } + + OutputAnalyzer output = CommandLineOptionTest.startVMWithOptions(optionNames, expectedValues); + + // check for option deprecation messages: + output.shouldHaveExitValue(0); + for (String[] deprecated : optionInfo) { + String match = getDeprecationString(deprecated[0]); + output.shouldMatch(match); + } + } + + public static void main(String[] args) throws Throwable { + testDeprecated(DEPRECATED_OPTIONS); // Make sure that each deprecated option is mentioned in the output. + } +}