6911854: Update TestElementsAnnotatedWith.java to use @compile/proc

Fri, 18 Dec 2009 11:15:23 -0800

author
darcy
date
Fri, 18 Dec 2009 11:15:23 -0800
changeset 453
96c71cbc544b
parent 452
0666a8f87661
child 454
ac5b4c5644ce

6911854: Update TestElementsAnnotatedWith.java to use @compile/proc
Reviewed-by: jjg

test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Tue Dec 15 13:26:06 2009 -0800
     1.2 +++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Fri Dec 18 11:15:23 2009 -0800
     1.3 @@ -23,7 +23,7 @@
     1.4  
     1.5  /*
     1.6   * @test
     1.7 - * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938
     1.8 + * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854
     1.9   * @summary Tests that getElementsAnnotatedWith works properly.
    1.10   * @author  Joseph D. Darcy
    1.11   * @compile TestElementsAnnotatedWith.java
    1.12 @@ -33,8 +33,8 @@
    1.13   * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
    1.14   * @compile -processor TestElementsAnnotatedWith -proc:only C2.java
    1.15   * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
    1.16 - * @compile -XD-d=. Foo.java
    1.17 - * @compile -processor TestElementsAnnotatedWith -proc:only TestElementsAnnotatedWith.java
    1.18 + * @compile Foo.java
    1.19 + * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
    1.20   */
    1.21  
    1.22  import java.lang.annotation.Annotation;
    1.23 @@ -89,7 +89,7 @@
    1.24                  // Verify that the annotation information is as
    1.25                  // expected.
    1.26  
    1.27 -                Set<String> expectedNames = new HashSet<String>(Arrays.asList(annotatedElementInfo.names()));
    1.28 +                Set<String> expectedNames = new HashSet<>(Arrays.asList(annotatedElementInfo.names()));
    1.29  
    1.30                  resultsMeta =
    1.31                      roundEnvironment.
    1.32 @@ -126,9 +126,6 @@
    1.33                  System.err.println("AnnotatedElementInfo: " + annotatedElementInfo);
    1.34                  throw new RuntimeException();
    1.35              }
    1.36 -
    1.37 -            if("TestElementsAnnotatedWith".equals(firstType.getSimpleName().toString()))
    1.38 -               writeClassFile(); // Start another round to test class file input
    1.39          } else {
    1.40              // If processing is over without an error, the specified
    1.41              // elements should be empty so an empty set should be returned.
    1.42 @@ -163,48 +160,14 @@
    1.43          } catch(IllegalArgumentException iae) {}
    1.44  
    1.45          try {
    1.46 -            Set<? extends Element> elements = roundEnvironment.getElementsAnnotatedWith(processingEnv.
    1.47 -                                                                                        getElementUtils().
    1.48 -                                                                                        getTypeElement("java.lang.Object") );
    1.49 +            Set<? extends Element> elements =
    1.50 +                roundEnvironment.getElementsAnnotatedWith(processingEnv.
    1.51 +                                                          getElementUtils().
    1.52 +                                                          getTypeElement("java.lang.Object") );
    1.53              throw new RuntimeException("Illegal argument exception not thrown");
    1.54          } catch(IllegalArgumentException iae) {}
    1.55      }
    1.56  
    1.57 -    /*
    1.58 -     * Hack alert!  The class file read below is generated by the
    1.59 -     * "@compile -XD-d=. Foo.java" directive above.  This sneakily
    1.60 -     * overrides the output location to the current directory where a
    1.61 -     * subsequent @compile can read the file.  This could be improved
    1.62 -     * if either a new directive like @process accepted class file
    1.63 -     * arguments (the javac command accepts such arguments but
    1.64 -     * @compile does not) or the test.src and test.classes properties
    1.65 -     * were set to be read with @compile jobs.
    1.66 -     */
    1.67 -    private void writeClassFile() {
    1.68 -        try {
    1.69 -            Filer filer = processingEnv.getFiler();
    1.70 -            JavaFileObject jfo = filer.createClassFile("Foo");
    1.71 -            OutputStream os = jfo.openOutputStream();
    1.72 -            // Copy the bytes over
    1.73 -            System.out.println((new File(".")).getAbsolutePath());
    1.74 -            InputStream io = new BufferedInputStream(new FileInputStream(new File(".", "Foo.class")));
    1.75 -            try {
    1.76 -                int datum = io.read();
    1.77 -                while(datum != -1) {
    1.78 -                    os.write(datum);
    1.79 -                    datum = io.read();
    1.80 -                }
    1.81 -            } finally {
    1.82 -                io.close();
    1.83 -            }
    1.84 -            os.close();
    1.85 -        } catch (IOException ioe) {
    1.86 -            throw new RuntimeException(ioe);
    1.87 -        }
    1.88 -
    1.89 -
    1.90 -    }
    1.91 -
    1.92      @Override
    1.93      public SourceVersion getSupportedSourceVersion() {
    1.94          return SourceVersion.latest();

mercurial