< prev index next >

test/gc/arguments/TestUnrecognizedVMOptionsHandling.java

Print this page




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


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