< prev index next >

test/tools/javac/file/T7018098.java

Print this page




  43 import com.sun.tools.javac.file.FSInfo;
  44 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  45 import com.sun.tools.javac.util.Context;
  46 
  47 @SupportedOptions("expect")
  48 public class T7018098 extends JavacTestingAbstractProcessor {
  49     public static void main(String... args) throws Exception {
  50         new T7018098().run();
  51     }
  52 
  53     static File testDir = new File("T7018098.dir");
  54 
  55     void run() throws Exception {
  56         String myName = T7018098.class.getSimpleName();
  57         File testSrc = new File(System.getProperty("test.src"));
  58         File file = new File(testSrc, myName + ".java");
  59 
  60         _assert(!testDir.exists());
  61 
  62         compile(
  63             "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
  64             "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
  65             "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  66             "-XDaccessInternalAPI",
  67             "-proc:only",
  68             "-processor", myName,
  69             "-Aexpect=false",
  70             file.getPath());
  71 
  72         testDir.mkdirs();
  73         _assert(testDir.exists());
  74 
  75         compile(
  76             "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
  77             "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
  78             "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  79             "-XDaccessInternalAPI",
  80             "-proc:only",
  81             "-processor", myName,
  82             "-Aexpect=true",
  83             file.getPath());
  84     }
  85 
  86     void _assert(boolean cond) {
  87         if (!cond)
  88             throw new AssertionError();
  89     }
  90 
  91     void compile(String... args) throws Exception {
  92         StringWriter sw = new StringWriter();
  93         PrintWriter pw = new PrintWriter(sw);
  94         int rc = com.sun.tools.javac.Main.compile(args, pw);
  95         pw.close();
  96         String out = sw.toString();
  97         if (!out.isEmpty())
  98             System.err.println(out);




  43 import com.sun.tools.javac.file.FSInfo;
  44 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  45 import com.sun.tools.javac.util.Context;
  46 
  47 @SupportedOptions("expect")
  48 public class T7018098 extends JavacTestingAbstractProcessor {
  49     public static void main(String... args) throws Exception {
  50         new T7018098().run();
  51     }
  52 
  53     static File testDir = new File("T7018098.dir");
  54 
  55     void run() throws Exception {
  56         String myName = T7018098.class.getSimpleName();
  57         File testSrc = new File(System.getProperty("test.src"));
  58         File file = new File(testSrc, myName + ".java");
  59 
  60         _assert(!testDir.exists());
  61 
  62         compile(
  63             "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
  64             "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
  65             "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  66             "-XDaccessInternalAPI",
  67             "-proc:only",
  68             "-processor", myName,
  69             "-Aexpect=false",
  70             file.getPath());
  71 
  72         testDir.mkdirs();
  73         _assert(testDir.exists());
  74 
  75         compile(
  76             "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
  77             "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
  78             "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  79             "-XDaccessInternalAPI",
  80             "-proc:only",
  81             "-processor", myName,
  82             "-Aexpect=true",
  83             file.getPath());
  84     }
  85 
  86     void _assert(boolean cond) {
  87         if (!cond)
  88             throw new AssertionError();
  89     }
  90 
  91     void compile(String... args) throws Exception {
  92         StringWriter sw = new StringWriter();
  93         PrintWriter pw = new PrintWriter(sw);
  94         int rc = com.sun.tools.javac.Main.compile(args, pw);
  95         pw.close();
  96         String out = sw.toString();
  97         if (!out.isEmpty())
  98             System.err.println(out);


< prev index next >