< prev index next >

langtools/test/tools/javac/modules/EnvVarTest.java

Print this page




  46 
  47     @Test
  48     public void testAddExports(Path base) throws Exception {
  49         Path src = base.resolve("src");
  50         // the package in the following call should be one that is not
  51         // available by default, including via @modules
  52         tb.writeJavaFiles(src,
  53             "package p; public class C { com.sun.tools.javac.jvm.Target t; }");
  54         Path classes = base.resolve("classes");
  55         tb.createDirectories(classes);
  56 
  57         tb.out.println("test that compilation fails if addExports is not provided");
  58         new JavacTask(tb)
  59                 .outdir(classes)
  60                 .files(findJavaFiles(src))
  61                 .run(Expect.FAIL)
  62                 .writeAll();
  63 
  64         tb.out.println("test that addExports can be given to javac");
  65         new JavacTask(tb)
  66                 .options("-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
  67                 .outdir(classes)
  68                 .files(findJavaFiles(src))
  69                 .run(Expect.SUCCESS)
  70                 .writeAll();
  71 
  72         tb.out.println("test that addExports can be provided with env variable");
  73         new JavacTask(tb, Mode.EXEC)
  74                 .envVar("_JAVAC_OPTIONS", "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
  75                 .outdir(classes)
  76                 .files(findJavaFiles(src))
  77                 .run(Expect.SUCCESS)
  78                 .writeAll();
  79 
  80         tb.out.println("test that addExports can be provided with env variable using @file");
  81         Path atFile = src.resolve("at-file.txt");
  82         tb.writeFile(atFile,
  83                 "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED");
  84 
  85         new JavacTask(tb, Mode.EXEC)
  86                 .envVar("_JAVAC_OPTIONS", "@" + atFile)
  87                 .outdir(classes)
  88                 .files(findJavaFiles(src))
  89                 .run(Expect.SUCCESS)
  90                 .writeAll();
  91     }
  92 
  93 }
  94 


  46 
  47     @Test
  48     public void testAddExports(Path base) throws Exception {
  49         Path src = base.resolve("src");
  50         // the package in the following call should be one that is not
  51         // available by default, including via @modules
  52         tb.writeJavaFiles(src,
  53             "package p; public class C { com.sun.tools.javac.jvm.Target t; }");
  54         Path classes = base.resolve("classes");
  55         tb.createDirectories(classes);
  56 
  57         tb.out.println("test that compilation fails if addExports is not provided");
  58         new JavacTask(tb)
  59                 .outdir(classes)
  60                 .files(findJavaFiles(src))
  61                 .run(Expect.FAIL)
  62                 .writeAll();
  63 
  64         tb.out.println("test that addExports can be given to javac");
  65         new JavacTask(tb)
  66                 .options("--add-exports", "jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
  67                 .outdir(classes)
  68                 .files(findJavaFiles(src))
  69                 .run(Expect.SUCCESS)
  70                 .writeAll();
  71 
  72         tb.out.println("test that addExports can be provided with env variable");
  73         new JavacTask(tb, Mode.EXEC)
  74                 .envVar("_JAVAC_OPTIONS", "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
  75                 .outdir(classes)
  76                 .files(findJavaFiles(src))
  77                 .run(Expect.SUCCESS)
  78                 .writeAll();
  79 
  80         tb.out.println("test that addExports can be provided with env variable using @file");
  81         Path atFile = src.resolve("at-file.txt");
  82         tb.writeFile(atFile,
  83                 "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED");
  84 
  85         new JavacTask(tb, Mode.EXEC)
  86                 .envVar("_JAVAC_OPTIONS", "@" + atFile)
  87                 .outdir(classes)
  88                 .files(findJavaFiles(src))
  89                 .run(Expect.SUCCESS)
  90                 .writeAll();
  91     }
  92 
  93 }
  94 
< prev index next >