test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java
author thartmann
Thu, 22 Mar 2018 08:39:51 +0100
changeset 49483 d374b1634589
parent 49185 5d1b75086f98
child 50040 a7d4b4d78c37
permissions -rw-r--r--
8199777: Deprecate -XX:+AggressiveOpts Summary: Deprecate -XX:+AggressiveOpts and remove it from testing. Reviewed-by: kvn, dholmes, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     1
/*
48885
00e159258897 8196806: Deprecate VMThreadHintNoPreempt and CompilerThreadHintNoPreempt
coleenp
parents: 48365
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     4
 *
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     8
 *
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    13
 * accompanied this code).
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    14
 *
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    18
 *
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    21
 * questions.
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    22
 */
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    23
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    24
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    25
import jdk.test.lib.process.OutputAnalyzer;
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    26
import jdk.test.lib.cli.*;
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    27
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    28
/*
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    29
 * @test
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    30
 * @bug 8066821
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    31
 * @summary Test that various options are deprecated. See deprecated_jvm_flags in arguments.cpp.
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 36099
diff changeset
    32
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 38152
diff changeset
    33
 * @library /test/lib
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    34
 */
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    35
public class VMDeprecatedOptions {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    36
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    37
    /**
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    38
     * each entry is {[0]: option name, [1]: value to set
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    39
     * (true/false/n/string)}.
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    40
     */
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    41
    public static final String[][] DEPRECATED_OPTIONS = {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    42
        // deprecated non-alias flags:
46655
d5ecb8ef2b93 8140284: Deprecate -XX:+UnsyncloadClass and -XX:+MustCallLoadClassInternal
hseigel
parents: 43605
diff changeset
    43
        {"MaxGCMinorPauseMillis",     "1032"},
47100
17953cf82d51 8186248: Allow more flexibility in selecting Heap % of available RAM
bobv
parents: 46655
diff changeset
    44
        {"MaxRAMFraction",            "8"},
17953cf82d51 8186248: Allow more flexibility in selecting Heap % of available RAM
bobv
parents: 46655
diff changeset
    45
        {"MinRAMFraction",            "2"},
17953cf82d51 8186248: Allow more flexibility in selecting Heap % of available RAM
bobv
parents: 46655
diff changeset
    46
        {"InitialRAMFraction",        "64"},
47572
552a97e8edad 8185062: Set AssumeMP to true and deprecate the flag
dholmes
parents: 47216
diff changeset
    47
        {"AssumeMP",                  "false"},
48108
9d00b6f9cbed 8191782: Missing deprecated options in VMDeprecatedOptions.java
rehn
parents: 47903
diff changeset
    48
        {"UseMembar",                 "true"},
48885
00e159258897 8196806: Deprecate VMThreadHintNoPreempt and CompilerThreadHintNoPreempt
coleenp
parents: 48365
diff changeset
    49
        {"CompilerThreadHintNoPreempt", "true"},
00e159258897 8196806: Deprecate VMThreadHintNoPreempt and CompilerThreadHintNoPreempt
coleenp
parents: 48365
diff changeset
    50
        {"VMThreadHintNoPreempt",       "false"},
49185
5d1b75086f98 8191421: Deprecate PrintSafepointStatistics, PrintSafepointStatisticsTimeout and PrintSafepointStatisticsCount options
coleenp
parents: 49037
diff changeset
    51
        {"PrintSafepointStatistics",    "false"},
5d1b75086f98 8191421: Deprecate PrintSafepointStatistics, PrintSafepointStatisticsTimeout and PrintSafepointStatisticsCount options
coleenp
parents: 49037
diff changeset
    52
        {"PrintSafepointStatisticsCount", "3"},
5d1b75086f98 8191421: Deprecate PrintSafepointStatistics, PrintSafepointStatisticsTimeout and PrintSafepointStatisticsCount options
coleenp
parents: 49037
diff changeset
    53
        {"PrintSafepointStatisticsTimeout", "3"},
49483
d374b1634589 8199777: Deprecate -XX:+AggressiveOpts
thartmann
parents: 49185
diff changeset
    54
        {"AggressiveOpts", "true"},
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    55
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    56
        // deprecated alias flags (see also aliased_jvm_flags):
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    57
        {"DefaultMaxRAMFraction", "4"},
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    58
        {"CreateMinidumpOnCrash", "false"}
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    59
    };
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    60
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    61
    static String getDeprecationString(String optionName) {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    62
        return "Option " + optionName
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    63
            + " was deprecated in version [\\S]+ and will likely be removed in a future release";
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    64
    }
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    65
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    66
    static void testDeprecated(String[][] optionInfo) throws Throwable {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    67
        String optionNames[] = new String[optionInfo.length];
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    68
        String expectedValues[] = new String[optionInfo.length];
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    69
        for (int i = 0; i < optionInfo.length; i++) {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    70
            optionNames[i] = optionInfo[i][0];
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    71
            expectedValues[i] = optionInfo[i][1];
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    72
        }
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    73
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    74
        OutputAnalyzer output = CommandLineOptionTest.startVMWithOptions(optionNames, expectedValues);
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    75
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    76
        // check for option deprecation messages:
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    77
        output.shouldHaveExitValue(0);
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    78
        for (String[] deprecated : optionInfo) {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    79
            String match = getDeprecationString(deprecated[0]);
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    80
            output.shouldMatch(match);
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    81
        }
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    82
    }
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
    83
47617
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    84
    // Deprecated diagnostic command line options need to be preceded on the
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    85
    // command line by -XX:+UnlockDiagnosticVMOptions.
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    86
    static void testDeprecatedDiagnostic(String option, String value)  throws Throwable {
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    87
        String XXoption = CommandLineOptionTest.prepareFlag(option, value);
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    88
        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    89
            CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS, XXoption, "-version");
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    90
        OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    91
        // check for option deprecation message:
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    92
        output.shouldHaveExitValue(0);
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    93
        String match = getDeprecationString(option);
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    94
        output.shouldMatch(match);
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    95
    }
44117bc2bedf 8188922: [TESTBUG] runtime/CommandLine/VMDeprecatedOptions.java fails with JDK10 release bits
hseigel
parents: 47572
diff changeset
    96
47903
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
    97
    // Deprecated experimental command line options need to be preceded on the
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
    98
    // command line by -XX:+UnlockExperimentalVMOption.
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
    99
    static void testDeprecatedExperimental(String option, String value)  throws Throwable {
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   100
        String XXoption = CommandLineOptionTest.prepareFlag(option, value);
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   101
        ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   102
            CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS, XXoption, "-version");
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   103
        OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   104
        // check for option deprecation message:
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   105
        output.shouldHaveExitValue(0);
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   106
        String match = getDeprecationString(option);
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   107
        output.shouldMatch(match);
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   108
    }
7f22774a5f42 8146115: Improve docker container detection and resource configuration usage
bobv
parents: 47776
diff changeset
   109
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
   110
    public static void main(String[] args) throws Throwable {
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
   111
        testDeprecated(DEPRECATED_OPTIONS);  // Make sure that each deprecated option is mentioned in the output.
47776
52e85a3fa0ab 8187347: Do not abort CDS archive creation when some classes are unverifiable
ccheung
parents: 47617
diff changeset
   112
        testDeprecatedDiagnostic("IgnoreUnverifiableClassesDuringDump", "false");
32823
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
   113
    }
ca8fef4cd57b 8066821: Enhance command line processing to manage deprecating and obsoleting -XX command line arguments
drwhite
parents:
diff changeset
   114
}