equal
deleted
inserted
replaced
66 } |
66 } |
67 } |
67 } |
68 |
68 |
69 static void testNoAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable { |
69 static void testNoAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable { |
70 Context context = new Context(); |
70 Context context = new Context(); |
71 fm.setContext(context); |
|
72 |
71 |
73 Main compilerMain = new Main("javac", new PrintWriter(System.err, true)); |
72 String[] args = { "-d", "." }; |
74 compilerMain.setOptions(Options.instance(context)); |
73 Main compilerMain = initCompilerMain(context, fm, args); |
75 compilerMain.filenames = new LinkedHashSet<File>(); |
|
76 compilerMain.processArgs(new String[] { "-d", "." }); |
|
77 |
74 |
78 JavaCompiler compiler = JavaCompiler.instance(context); |
75 JavaCompiler compiler = JavaCompiler.instance(context); |
79 compiler.compile(List.of(f)); |
76 compiler.compile(List.of(f)); |
80 try { |
77 try { |
81 compiler.compile(List.of(f)); |
78 compiler.compile(List.of(f)); |
85 } |
82 } |
86 } |
83 } |
87 |
84 |
88 static void testAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable { |
85 static void testAnnotationProcessing(JavacFileManager fm, JavaFileObject f) throws Throwable { |
89 Context context = new Context(); |
86 Context context = new Context(); |
90 fm.setContext(context); |
|
91 |
87 |
92 Main compilerMain = new Main("javac", new PrintWriter(System.err, true)); |
88 String[] args = { |
93 compilerMain.setOptions(Options.instance(context)); |
89 "-XprintRounds", |
94 compilerMain.filenames = new LinkedHashSet<File>(); |
90 "-processorpath", testClasses, |
95 compilerMain.processArgs(new String[] { |
91 "-processor", self, |
96 "-XprintRounds", |
92 "-d", "." |
97 "-processorpath", testClasses, |
93 }; |
98 "-processor", self, |
94 Main compilerMain = initCompilerMain(context, fm, args); |
99 "-d", "."}); |
|
100 |
95 |
101 JavaCompiler compiler = JavaCompiler.instance(context); |
96 JavaCompiler compiler = JavaCompiler.instance(context); |
102 compiler.compile(List.of(f)); |
97 compiler.compile(List.of(f)); |
103 try { |
98 try { |
104 compiler.compile(List.of(f)); |
99 compiler.compile(List.of(f)); |
106 } catch (AssertionError e) { |
101 } catch (AssertionError e) { |
107 System.err.println("Exception from compiler (expected): " + e); |
102 System.err.println("Exception from compiler (expected): " + e); |
108 } |
103 } |
109 } |
104 } |
110 |
105 |
|
106 static Main initCompilerMain(Context context, JavacFileManager fm, String... args) { |
|
107 fm.setContext(context); |
|
108 context.put(JavaFileManager.class, fm); |
|
109 |
|
110 Main compilerMain = new Main("javac", new PrintWriter(System.err, true)); |
|
111 compilerMain.setOptions(Options.instance(context)); |
|
112 compilerMain.filenames = new LinkedHashSet<File>(); |
|
113 compilerMain.deferredFileManagerOptions = new LinkedHashMap<>(); |
|
114 compilerMain.processArgs(args); |
|
115 fm.handleOptions(compilerMain.deferredFileManagerOptions); |
|
116 return compilerMain; |
|
117 } |
|
118 |
111 public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { |
119 public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { |
112 return true; |
120 return true; |
113 } |
121 } |
114 } |
122 } |