test/hotspot/jtreg/gc/arguments/TestUnrecognizedVMOptionsHandling.java
changeset 55610 47fdb5b0fa41
parent 53523 4c5184c56dc2
equal deleted inserted replaced
55609:377e49b3014c 55610:47fdb5b0fa41
    27  * @test TestUnrecognizedVMOptionsHandling
    27  * @test TestUnrecognizedVMOptionsHandling
    28  * @key gc
    28  * @key gc
    29  * @bug 8017611
    29  * @bug 8017611
    30  * @summary Tests handling unrecognized VM options
    30  * @summary Tests handling unrecognized VM options
    31  * @library /test/lib
    31  * @library /test/lib
       
    32  * @library /
    32  * @modules java.base/jdk.internal.misc
    33  * @modules java.base/jdk.internal.misc
    33  *          java.management
    34  *          java.management
    34  * @run main/othervm gc.arguments.TestUnrecognizedVMOptionsHandling
    35  * @run main/othervm gc.arguments.TestUnrecognizedVMOptionsHandling
    35  */
    36  */
    36 
    37 
    39 
    40 
    40 public class TestUnrecognizedVMOptionsHandling {
    41 public class TestUnrecognizedVMOptionsHandling {
    41 
    42 
    42   public static void main(String args[]) throws Exception {
    43   public static void main(String args[]) throws Exception {
    43     // The first two JAVA processes are expected to fail, but with a correct VM option suggestion
    44     // The first two JAVA processes are expected to fail, but with a correct VM option suggestion
    44     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    45     ProcessBuilder pb = GCArguments.createJavaProcessBuilder(
    45       "-XX:+UseDynamicNumberOfGcThreads",
    46       "-XX:+UseDynamicNumberOfGcThreads",
    46       "-version"
    47       "-version"
    47       );
    48       );
    48     OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start());
    49     OutputAnalyzer outputWithError = new OutputAnalyzer(pb.start());
    49     outputWithError.shouldContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?");
    50     outputWithError.shouldContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?");
    50     if (outputWithError.getExitValue() == 0) {
    51     if (outputWithError.getExitValue() == 0) {
    51       throw new RuntimeException("Not expected to get exit value 0");
    52       throw new RuntimeException("Not expected to get exit value 0");
    52     }
    53     }
    53 
    54 
    54     pb = ProcessTools.createJavaProcessBuilder(
    55     pb = GCArguments.createJavaProcessBuilder(
    55       "-XX:MaxiumHeapSize=500m",
    56       "-XX:MaxiumHeapSize=500m",
    56       "-version"
    57       "-version"
    57       );
    58       );
    58     outputWithError = new OutputAnalyzer(pb.start());
    59     outputWithError = new OutputAnalyzer(pb.start());
    59     outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?");
    60     outputWithError.shouldContain("Did you mean 'MaxHeapSize=<value>'?");
    60     if (outputWithError.getExitValue() == 0) {
    61     if (outputWithError.getExitValue() == 0) {
    61       throw new RuntimeException("Not expected to get exit value 0");
    62       throw new RuntimeException("Not expected to get exit value 0");
    62     }
    63     }
    63 
    64 
    64     // The last JAVA process should run successfully for the purpose of sanity check
    65     // The last JAVA process should run successfully for the purpose of sanity check
    65     pb = ProcessTools.createJavaProcessBuilder(
    66     pb = GCArguments.createJavaProcessBuilder(
    66       "-XX:+UseDynamicNumberOfGCThreads",
    67       "-XX:+UseDynamicNumberOfGCThreads",
    67       "-version"
    68       "-version"
    68       );
    69       );
    69     OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start());
    70     OutputAnalyzer outputWithNoError = new OutputAnalyzer(pb.start());
    70     outputWithNoError.shouldNotContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?");
    71     outputWithNoError.shouldNotContain("Did you mean '(+/-)UseDynamicNumberOfGCThreads'?");