< prev index next >

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

Print this page
rev 50958 : imported patch 8189747

*** 21,31 **** * questions. */ /** * @test ! * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 * @summary Verify that annotation processing works. * @library /tools/lib * @modules * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main --- 21,31 ---- * questions. */ /** * @test ! * @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,1425 **** --- 1416,1438 ---- .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,1515 **** --- 1519,1551 ---- } 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 >