test/tools/javac/processing/filer/TestPackageInfo.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -24,10 +24,12 @@
 /*
  * @test
  * @bug 6380018 6392177
  * @summary Test the ability to create and process package-info.java files
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile TestPackageInfo.java
  * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java
  */
 
 import java.util.Set;

@@ -47,30 +49,20 @@
 /**
  * Test the ability to process annotations on package-info.java files:
  * 1) Visibility of package-info files from the command line
  * 2) Visibility of generated package-info.java source files
  */
-@SupportedAnnotationTypes("*")
-public class TestPackageInfo extends AbstractProcessor {
-    private Elements eltUtils;
-    private Messager messager;
-    private Filer filer;
-    private Map<String,String> options;
-
+public class TestPackageInfo extends JavacTestingAbstractProcessor {
     private int round = 0;
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
         round++;
 
         // Verify annotations are as expected
         Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>();
-        if (round == 1)
-            expectedAnnotations.add(eltUtils.
-                                    getTypeElement("javax.annotation.processing.SupportedAnnotationTypes"));
-        expectedAnnotations.add(eltUtils.
-                                getTypeElement("java.lang.SuppressWarnings"));
+        expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings"));
 
         if (!roundEnv.processingOver()) {
             System.out.println("\nRound " + round);
             int rootElementSize = roundEnv.getRootElements().size();
 

@@ -125,18 +117,6 @@
                 throw new RuntimeException("Unexpected round number " + round);
             }
         }
         return false;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        eltUtils = processingEnv.getElementUtils();
-        messager = processingEnv.getMessager();
-        filer    = processingEnv.getFiler();
-        options  = processingEnv.getOptions();
-    }
 }