< prev index next >

test/tools/javac/util/T6597678.java

Print this page




  42 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  43 import com.sun.tools.javac.util.Context;
  44 import com.sun.tools.javac.util.JavacMessages;
  45 import com.sun.tools.javac.util.Log;
  46 
  47 @SupportedOptions("WriterString")
  48 public class T6597678 extends JavacTestingAbstractProcessor {
  49     public static void main(String... args) throws Exception {
  50         new T6597678().run();
  51     }
  52 
  53     void run() throws Exception {
  54         String myName = T6597678.class.getSimpleName();
  55         File testSrc = new File(System.getProperty("test.src"));
  56         File file = new File(testSrc, myName + ".java");
  57 
  58         StringWriter sw = new StringWriter();
  59         PrintWriter pw = new PrintWriter(sw);
  60 
  61         compile(sw, pw,
  62             "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
  63             "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  64             "-XDaccessInternalAPI",
  65             "-proc:only",
  66             "-processor", myName,
  67             "-AWriterString=" + pw.toString(),
  68             file.getPath());
  69     }
  70 
  71     void compile(StringWriter sw, PrintWriter pw, String... args) throws Exception {
  72         int rc = com.sun.tools.javac.Main.compile(args, pw);
  73         pw.close();
  74         String out = sw.toString();
  75         if (!out.isEmpty())
  76             System.err.println(out);
  77         if (rc != 0)
  78             throw new Exception("compilation failed unexpectedly: rc=" + rc);
  79     }
  80 
  81     //---------------
  82 
  83     @Override




  42 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
  43 import com.sun.tools.javac.util.Context;
  44 import com.sun.tools.javac.util.JavacMessages;
  45 import com.sun.tools.javac.util.Log;
  46 
  47 @SupportedOptions("WriterString")
  48 public class T6597678 extends JavacTestingAbstractProcessor {
  49     public static void main(String... args) throws Exception {
  50         new T6597678().run();
  51     }
  52 
  53     void run() throws Exception {
  54         String myName = T6597678.class.getSimpleName();
  55         File testSrc = new File(System.getProperty("test.src"));
  56         File file = new File(testSrc, myName + ".java");
  57 
  58         StringWriter sw = new StringWriter();
  59         PrintWriter pw = new PrintWriter(sw);
  60 
  61         compile(sw, pw,
  62             "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
  63             "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
  64             "-XDaccessInternalAPI",
  65             "-proc:only",
  66             "-processor", myName,
  67             "-AWriterString=" + pw.toString(),
  68             file.getPath());
  69     }
  70 
  71     void compile(StringWriter sw, PrintWriter pw, String... args) throws Exception {
  72         int rc = com.sun.tools.javac.Main.compile(args, pw);
  73         pw.close();
  74         String out = sw.toString();
  75         if (!out.isEmpty())
  76             System.err.println(out);
  77         if (rc != 0)
  78             throw new Exception("compilation failed unexpectedly: rc=" + rc);
  79     }
  80 
  81     //---------------
  82 
  83     @Override


< prev index next >