< prev index next >

test/langtools/tools/javac/modules/AnnotationsOnModules.java

Print this page

        

@@ -27,23 +27,21 @@
  * @summary Test annotations on module declaration.
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.jdeps/com.sun.tools.classfile
- * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase
+ * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase ProxyTypeValidator
  * @run main AnnotationsOnModules
  */
 
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Objects;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import javax.annotation.processing.AbstractProcessor;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
 import javax.annotation.processing.SupportedOptions;

@@ -677,36 +675,16 @@
 
             new JavacTask(tb)
                 .options("--module-path", modulePath.toString(),
                          "--add-modules", "m",
                          "-processorpath", System.getProperty("test.classes"),
-                         "-processor", ProxyTypeValidator.class.getName(),
+                         "-processor", "ProxyTypeValidator",
                          "-A" + OPT_EXPECTED_ANNOTATIONS + "=" + tc.expectedAnnotations)
                 .outdir(classes)
                 .files(findJavaFiles(extraSrc))
                 .run()
                 .writeAll();
         }
     }
 
     private static final String OPT_EXPECTED_ANNOTATIONS = "expectedAnnotations";
-
-    @SupportedAnnotationTypes("*")
-    @SupportedOptions(OPT_EXPECTED_ANNOTATIONS)
-    public static final class ProxyTypeValidator extends AbstractProcessor {
-
-        @Override
-        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
-            ModuleElement m = processingEnv.getElementUtils().getModuleElement("m");
-            String actualTypes = m.getAnnotationMirrors()
-                                  .stream()
-                                  .map(am -> am.toString())
-                                  .collect(Collectors.joining(", "));
-            if (!Objects.equals(actualTypes, processingEnv.getOptions().get(OPT_EXPECTED_ANNOTATIONS))) {
-                throw new IllegalStateException("Expected annotations not found, actual: " + actualTypes);
-            }
-            return false;
-        }
-
-    }
-
 }
< prev index next >