test/hotspot/jtreg/runtime/CommandLine/VMOptionWarning.java
author iignatyev
Fri, 02 Nov 2018 16:27:55 -0700
changeset 52396 e292e94b448a
parent 47774 69c081ca110a
permissions -rw-r--r--
8213058: remove ExecuteInternalVMTests and VerboseInternalVMTests flags Reviewed-by: erikj, dholmes, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     1
/*
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47216
diff changeset
     2
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     4
 *
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     8
 *
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    13
 * accompanied this code).
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    14
 *
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    18
 *
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    21
 * questions.
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    22
 */
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    23
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    24
/*
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    25
 * @test
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    26
 * @bug 8027314
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    27
 * @summary Warn if diagnostic or experimental vm option is used and -XX:+UnlockDiagnosticVMOptions or -XX:+UnlockExperimentalVMOptions, respectively, isn't specified. Warn if develop or notproduct vm option is used with product version of VM.
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    28
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 34285
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 22518
diff changeset
    30
 *          java.management
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    31
 */
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    32
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    33
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    34
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    35
import jdk.test.lib.Platform;
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    36
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    37
public class VMOptionWarning {
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47216
diff changeset
    39
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version");
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    40
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
47774
69c081ca110a 8184765: Dynamically resize SystemDictionary
gziemski
parents: 47216
diff changeset
    41
        output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.");
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    42
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    43
        if (Platform.isDebugBuild()) {
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    44
            System.out.println("Skip the rest of the tests on debug builds since diagnostic, develop, and notproduct options are available on debug builds.");
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    45
            return;
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    46
        }
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    47
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    48
        pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintInlining", "-version");
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    49
        output = new OutputAnalyzer(pb.start());
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    50
        output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    51
34285
0b07014c15e9 8143155: Remove TraceRuntimeCalls, TraceJNICalls, and TraceJVMCalls rather than convert to UL
rprotacio
parents: 30604
diff changeset
    52
        pb = ProcessTools.createJavaProcessBuilder("-XX:+VerifyStack", "-version");
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    53
        output = new OutputAnalyzer(pb.start());
34285
0b07014c15e9 8143155: Remove TraceRuntimeCalls, TraceJNICalls, and TraceJVMCalls rather than convert to UL
rprotacio
parents: 30604
diff changeset
    54
        output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM.");
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    55
52396
e292e94b448a 8213058: remove ExecuteInternalVMTests and VerboseInternalVMTests flags
iignatyev
parents: 47774
diff changeset
    56
        pb = ProcessTools.createJavaProcessBuilder("-XX:+CheckCompressedOops", "-version");
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    57
        output = new OutputAnalyzer(pb.start());
52396
e292e94b448a 8213058: remove ExecuteInternalVMTests and VerboseInternalVMTests flags
iignatyev
parents: 47774
diff changeset
    58
        output.shouldContain("Error: VM option 'CheckCompressedOops' is notproduct and is available only in debug version of VM.");
22518
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    59
    }
e23c5545e376 8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message
ccheung
parents:
diff changeset
    60
}