36
import javax.annotation.processing.*;
37
import javax.lang.model.element.*;
39
import com.sun.source.util.*;
40
import com.sun.tools.javac.api.*;
41
import com.sun.tools.javac.file.JavacFileManager;
42
import com.sun.tools.javac.util.*;
45
@SupportedAnnotationTypes("*")
46
public class T6358024 extends AbstractProcessor {
47
static JavacFileManager fm;
48
public static void main(String... args) throws Throwable {
49
String self = T6358024.class.getName();
51
String testSrc = System.getProperty("test.src");
53
fm = new JavacFileManager(new Context(), false, null);
54
JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java");
57
new Option[] { new Option("-d", ".")},
61
new Option[] { new XOption("-XprintRounds"),
62
new Option("-processorpath", "."),
63
new Option("-processor", self) },
67
static void test(JavacFileManager fm, JavaFileObject f, Option[] opts, int expect) throws Throwable {
68
PrintWriter out = new PrintWriter(System.err, true);
70
JavacTool tool = JavacTool.create();
71
List<String> flags = new ArrayList<String>();
72
flags.addAll(Arrays.asList(
73
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
74
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
75
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"));
76
for (Option opt: opts) {
78
for (Object arg : opt.args)
79
flags.add(arg.toString());
82
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(out,
88
MyTaskListener tl = new MyTaskListener();
89
task.setTaskListener(tl);
91
if (tl.started != expect)
92
throw new AssertionError("Unexpected number of TaskListener events; "
93
+ "expected " + expect + ", found " + tl.started);
96
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
100
static class MyTaskListener implements TaskListener {
101
public void started(TaskEvent e) {
102
System.err.println("Started: " + e);
105
public void finished(TaskEvent e) {
111
static class Option {
112
Option(String name, String... args) {
116
public final String name;
117
public final String[] args;
120
static class XOption extends Option {
121
XOption(String name, String... args) {