Path: blob/master/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
40942 views
/*1* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import jdk.test.lib.process.ProcessTools;24import jdk.test.lib.process.OutputAnalyzer;25import jdk.test.lib.cli.*;2627/*28* @test29* @bug 806682130* @summary Test that various options are deprecated. See deprecated_jvm_flags in arguments.cpp.31* @modules java.base/jdk.internal.misc32* @library /test/lib33* @run driver VMDeprecatedOptions34*/35public class VMDeprecatedOptions {3637/**38* each entry is {[0]: option name, [1]: value to set39* (true/false/n/string)}.40*/41public static final String[][] DEPRECATED_OPTIONS = {42// deprecated non-alias flags:43{"MaxGCMinorPauseMillis", "1032"},44{"MaxRAMFraction", "8"},45{"MinRAMFraction", "2"},46{"InitialRAMFraction", "64"},47{"TLABStats", "false"},48{"AllowRedefinitionToAddDeleteMethods", "true"},4950// deprecated alias flags (see also aliased_jvm_flags):51{"DefaultMaxRAMFraction", "4"},52{"CreateMinidumpOnCrash", "false"}53};5455static String getDeprecationString(String optionName) {56return "Option " + optionName57+ " was deprecated in version [\\S]+ and will likely be removed in a future release";58}5960static void testDeprecated(String[][] optionInfo) throws Throwable {61String optionNames[] = new String[optionInfo.length];62String expectedValues[] = new String[optionInfo.length];63for (int i = 0; i < optionInfo.length; i++) {64optionNames[i] = optionInfo[i][0];65expectedValues[i] = optionInfo[i][1];66}6768OutputAnalyzer output = CommandLineOptionTest.startVMWithOptions(optionNames, expectedValues);6970// check for option deprecation messages:71output.shouldHaveExitValue(0);72for (String[] deprecated : optionInfo) {73String match = getDeprecationString(deprecated[0]);74output.shouldMatch(match);75}76}7778// Deprecated diagnostic command line options need to be preceded on the79// command line by -XX:+UnlockDiagnosticVMOptions.80static void testDeprecatedDiagnostic(String option, String value) throws Throwable {81String XXoption = CommandLineOptionTest.prepareFlag(option, value);82ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(83CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, XXoption, "-version");84OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());85// check for option deprecation message:86output.shouldHaveExitValue(0);87String match = getDeprecationString(option);88output.shouldMatch(match);89}9091// Deprecated experimental command line options need to be preceded on the92// command line by -XX:+UnlockExperimentalVMOption.93static void testDeprecatedExperimental(String option, String value) throws Throwable {94String XXoption = CommandLineOptionTest.prepareFlag(option, value);95ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(96CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, XXoption, "-version");97OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());98// check for option deprecation message:99output.shouldHaveExitValue(0);100String match = getDeprecationString(option);101output.shouldMatch(match);102}103104public static void main(String[] args) throws Throwable {105testDeprecated(DEPRECATED_OPTIONS); // Make sure that each deprecated option is mentioned in the output.106}107}108109110