test/tools/javac/util/T6597678.java

changeset 1044
4844a9fd3a62
parent 944
83260b3305ac
child 1159
4261dc8af622
     1.1 --- a/test/tools/javac/util/T6597678.java	Mon Jun 13 12:17:14 2011 -0700
     1.2 +++ b/test/tools/javac/util/T6597678.java	Wed Jun 22 17:07:02 2011 -0700
     1.3 @@ -23,7 +23,7 @@
     1.4  
     1.5  /**
     1.6   * @test
     1.7 - * @bug 6597678
     1.8 + * @bug 6597678 6449184
     1.9   * @summary Ensure Messages propogated between rounds
    1.10   * @library ../lib
    1.11   * @build JavacTestingAbstractProcessor T6597678
    1.12 @@ -42,26 +42,28 @@
    1.13  import com.sun.tools.javac.util.Context;
    1.14  import com.sun.tools.javac.util.JavacMessages;
    1.15  
    1.16 +@SupportedOptions("WriterString")
    1.17  public class T6597678 extends JavacTestingAbstractProcessor {
    1.18      public static void main(String... args) throws Exception {
    1.19          new T6597678().run();
    1.20      }
    1.21  
    1.22 -
    1.23      void run() throws Exception {
    1.24          String myName = T6597678.class.getSimpleName();
    1.25          File testSrc = new File(System.getProperty("test.src"));
    1.26          File file = new File(testSrc, myName + ".java");
    1.27  
    1.28 -        compile(
    1.29 +        StringWriter sw = new StringWriter();
    1.30 +        PrintWriter pw = new PrintWriter(sw);
    1.31 +
    1.32 +        compile(sw, pw,
    1.33              "-proc:only",
    1.34              "-processor", myName,
    1.35 +            "-AWriterString=" + pw.toString(),
    1.36              file.getPath());
    1.37      }
    1.38  
    1.39 -    void compile(String... args) throws Exception {
    1.40 -        StringWriter sw = new StringWriter();
    1.41 -        PrintWriter pw = new PrintWriter(sw);
    1.42 +    void compile(StringWriter sw, PrintWriter pw, String... args) throws Exception {
    1.43          int rc = com.sun.tools.javac.Main.compile(args, pw);
    1.44          pw.close();
    1.45          String out = sw.toString();
    1.46 @@ -76,6 +78,7 @@
    1.47      @Override
    1.48      public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    1.49          Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    1.50 +        PrintWriter out = ((JavacProcessingEnvironment) processingEnv).getWriter();
    1.51          Locale locale = context.get(Locale.class);
    1.52          JavacMessages messages = context.get(JavacMessages.messagesKey);
    1.53  
    1.54 @@ -83,9 +86,13 @@
    1.55          if (round == 1) {
    1.56              initialLocale = locale;
    1.57              initialMessages = messages;
    1.58 +            initialWriter = out;
    1.59 +
    1.60 +            checkEqual("writerString", out.toString().intern(), options.get("WriterString").intern());
    1.61          } else {
    1.62              checkEqual("locale", locale, initialLocale);
    1.63              checkEqual("messages", messages, initialMessages);
    1.64 +            checkEqual("writer", out, initialWriter);
    1.65          }
    1.66  
    1.67          return true;
    1.68 @@ -102,4 +109,5 @@
    1.69      int round = 0;
    1.70      Locale initialLocale;
    1.71      JavacMessages initialMessages;
    1.72 +    PrintWriter initialWriter;
    1.73  }

mercurial