< prev index next >

langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java

Print this page




  71                 .run();
  72     }
  73 
  74 
  75     // test with bootclasspath, for as long as its around
  76     void testBootClassPath() {
  77         String[] bcpOpts = { "-Xlint:-options", "-source", "8", "-bootclasspath", "." };
  78         test(bcpOpts, compilerErrorMessage);
  79     }
  80 
  81     // test with module path
  82     void testModulePath() throws Exception {
  83         // need to ensure there is an empty java.base to avoid different error message
  84         Files.createDirectories(Paths.get("modules/java.base"));
  85         new JavacTask(tb)
  86                 .sources("module java.base { }")
  87                 .outdir("modules/java.base")
  88                 .run();
  89 
  90         // ideally we'd have a better message for this case
  91         String[] mpOpts = { "-system", "none", "-modulepath", "modules" };
  92         test(mpOpts, compilerErrorMessage);
  93     }
  94 
  95     private void test(String[] options, String expect) {
  96         System.err.println("Testing " + java.util.Arrays.toString(options));
  97 
  98         String out = new JavacTask(tb)
  99                 .options(options)
 100                 .sources(noJavaLangSrc)
 101                 .run(Task.Expect.FAIL, 3)
 102                 .writeAll()
 103                 .getOutput(Task.OutputKind.DIRECT);
 104 
 105         if (!out.trim().equals(expect)) {
 106             throw new AssertionError("javac generated error output is not correct");
 107         }
 108 
 109         System.err.println("OK");
 110     }
 111 


  71                 .run();
  72     }
  73 
  74 
  75     // test with bootclasspath, for as long as its around
  76     void testBootClassPath() {
  77         String[] bcpOpts = { "-Xlint:-options", "-source", "8", "-bootclasspath", "." };
  78         test(bcpOpts, compilerErrorMessage);
  79     }
  80 
  81     // test with module path
  82     void testModulePath() throws Exception {
  83         // need to ensure there is an empty java.base to avoid different error message
  84         Files.createDirectories(Paths.get("modules/java.base"));
  85         new JavacTask(tb)
  86                 .sources("module java.base { }")
  87                 .outdir("modules/java.base")
  88                 .run();
  89 
  90         // ideally we'd have a better message for this case
  91         String[] mpOpts = { "--system", "none", "--module-path", "modules" };
  92         test(mpOpts, compilerErrorMessage);
  93     }
  94 
  95     private void test(String[] options, String expect) {
  96         System.err.println("Testing " + java.util.Arrays.toString(options));
  97 
  98         String out = new JavacTask(tb)
  99                 .options(options)
 100                 .sources(noJavaLangSrc)
 101                 .run(Task.Expect.FAIL, 3)
 102                 .writeAll()
 103                 .getOutput(Task.OutputKind.DIRECT);
 104 
 105         if (!out.trim().equals(expect)) {
 106             throw new AssertionError("javac generated error output is not correct");
 107         }
 108 
 109         System.err.println("OK");
 110     }
 111 
< prev index next >