< prev index next >

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

Print this page
rev 50958 : imported patch 8189747

@@ -21,11 +21,11 @@
  * questions.
  */
 
 /**
  * @test
- * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119
+ * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 8189747
  * @summary Verify that annotation processing works.
  * @library /tools/lib
  * @modules
  *      jdk.compiler/com.sun.tools.javac.api
  *      jdk.compiler/com.sun.tools.javac.main

@@ -1416,10 +1416,23 @@
             .outdir(cpClasses)
             .files(findJavaFiles(src))
             .run()
             .writeAll();
 
+        //from source:
+        new JavacTask(tb)
+            .options("--module-source-path", moduleSrc.toString(),
+                     "--source-path", src.toString(),
+                     "-processorpath", System.getProperty("test.class.path"),
+                     "-processor", UnboundLookupGenerate.class.getName(),
+                     "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(moduleSrc))
+            .run()
+            .writeAll()
+            .getOutput(OutputKind.DIRECT);
+
     }
 
     @SupportedAnnotationTypes("*")
     public static final class UnboundLookup extends AbstractProcessor {
 

@@ -1506,10 +1519,33 @@
             }
 
             return false;
         }
 
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+
+    }
+
+    @SupportedAnnotationTypes("*")
+    public static final class UnboundLookupGenerate extends AbstractProcessor {
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (processingEnv.getElementUtils().getTypeElement("nue.Nue") == null) {
+                try (Writer w = processingEnv.getFiler().createSourceFile("m1x/nue.Nue").openWriter()) {
+                    w.write("package nue; public class Nue {}");
+                } catch (IOException ex) {
+                    throw new IllegalStateException(ex);
+                }
+            }
+
+            return false;
+        }
+
         @Override
         public SourceVersion getSupportedSourceVersion() {
             return SourceVersion.latest();
         }
 
< prev index next >