|
22 | 22 | */ |
23 | 23 |
|
24 | 24 | /* |
25 | | - * @test |
| 25 | + * @test VMOptionWarningExperimental |
26 | 26 | * @bug 8027314 |
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. |
| 27 | + * @summary Warn if experimental vm option is used and -XX:+UnlockExperimentalVMOptions isn't specified. |
28 | 28 | * @requires vm.flagless |
| 29 | + * @requires ! vm.opt.final.UnlockExperimentalVMOptions |
29 | 30 | * @library /test/lib |
30 | 31 | * @modules java.base/jdk.internal.misc |
31 | 32 | * java.management |
32 | | - * @run driver VMOptionWarning |
| 33 | + * @run driver VMOptionWarning Experimental |
| 34 | + */ |
| 35 | + |
| 36 | +/* @test VMOptionWarningDiagnostic |
| 37 | + * @bug 8027314 |
| 38 | + * @summary Warn if diagnostic vm option is used and -XX:+UnlockDiagnosticVMOptions isn't specified. |
| 39 | + * @requires vm.flagless |
| 40 | + * @requires ! vm.debug |
| 41 | + * @library /test/lib |
| 42 | + * @modules java.base/jdk.internal.misc |
| 43 | + * java.management |
| 44 | + * @run driver VMOptionWarning Diagnostic |
| 45 | + */ |
| 46 | + |
| 47 | +/* @test VMOptionWarningDevelop |
| 48 | + * @bug 8027314 |
| 49 | + * @summary Warn if develop or notproduct vm option is used with product version of VM. |
| 50 | + * @requires vm.flagless |
| 51 | + * @requires ! vm.debug |
| 52 | + * @library /test/lib |
| 53 | + * @modules java.base/jdk.internal.misc |
| 54 | + * java.management |
| 55 | + * @run driver VMOptionWarning Develop |
33 | 56 | */ |
34 | 57 |
|
35 | 58 | import jdk.test.lib.process.ProcessTools; |
|
38 | 61 |
|
39 | 62 | public class VMOptionWarning { |
40 | 63 | public static void main(String[] args) throws Exception { |
41 | | - ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version"); |
42 | | - OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
43 | | - output.shouldNotHaveExitValue(0); |
44 | | - output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions."); |
45 | | - |
46 | | - if (Platform.isDebugBuild()) { |
47 | | - System.out.println("Skip the rest of the tests on debug builds since diagnostic, develop, and notproduct options are available on debug builds."); |
48 | | - return; |
| 64 | + if (args.length != 1) { |
| 65 | + throw new RuntimeException("wrong number of args: " + args.length); |
49 | 66 | } |
50 | 67 |
|
51 | | - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version"); |
52 | | - output = new OutputAnalyzer(pb.start()); |
53 | | - output.shouldNotHaveExitValue(0); |
54 | | - output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions."); |
| 68 | + ProcessBuilder pb; |
| 69 | + OutputAnalyzer output; |
| 70 | + switch (args[0]) { |
| 71 | + case "Experimental": { |
| 72 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+AlwaysSafeConstructors", "-version"); |
| 73 | + output = new OutputAnalyzer(pb.start()); |
| 74 | + output.shouldNotHaveExitValue(0); |
| 75 | + output.shouldContain("Error: VM option 'AlwaysSafeConstructors' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions."); |
| 76 | + break; |
| 77 | + } |
| 78 | + case "Diagnostic": { |
| 79 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+PrintInlining", "-version"); |
| 80 | + output = new OutputAnalyzer(pb.start()); |
| 81 | + output.shouldNotHaveExitValue(0); |
| 82 | + output.shouldContain("Error: VM option 'PrintInlining' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions."); |
| 83 | + break; |
| 84 | + } |
| 85 | + case "Develop": { |
| 86 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version"); |
| 87 | + output = new OutputAnalyzer(pb.start()); |
| 88 | + output.shouldNotHaveExitValue(0); |
| 89 | + output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM."); |
55 | 90 |
|
56 | | - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+VerifyStack", "-version"); |
57 | | - output = new OutputAnalyzer(pb.start()); |
58 | | - output.shouldNotHaveExitValue(0); |
59 | | - output.shouldContain("Error: VM option 'VerifyStack' is develop and is available only in debug version of VM."); |
60 | | - |
61 | | - pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CheckCompressedOops", "-version"); |
62 | | - output = new OutputAnalyzer(pb.start()); |
63 | | - output.shouldNotHaveExitValue(0); |
64 | | - output.shouldContain("Error: VM option 'CheckCompressedOops' is notproduct and is available only in debug version of VM."); |
| 91 | + pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CheckCompressedOops", "-version"); |
| 92 | + output = new OutputAnalyzer(pb.start()); |
| 93 | + output.shouldNotHaveExitValue(0); |
| 94 | + output.shouldContain("Error: VM option 'CheckCompressedOops' is notproduct and is available only in debug version of VM."); |
| 95 | + break; |
| 96 | + } |
| 97 | + default: { |
| 98 | + throw new RuntimeException("Invalid argument: " + args[0]); |
| 99 | + } |
| 100 | + } |
65 | 101 | } |
66 | 102 | } |
0 commit comments