201 } else { |
203 } else { |
202 String processorNames = options.get("-processor"); |
204 String processorNames = options.get("-processor"); |
203 JavaFileManager fileManager = context.get(JavaFileManager.class); |
205 JavaFileManager fileManager = context.get(JavaFileManager.class); |
204 try { |
206 try { |
205 // If processorpath is not explicitly set, use the classpath. |
207 // If processorpath is not explicitly set, use the classpath. |
206 ClassLoader processorCL = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) |
208 processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) |
207 ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) |
209 ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) |
208 : fileManager.getClassLoader(CLASS_PATH); |
210 : fileManager.getClassLoader(CLASS_PATH); |
209 |
211 |
210 /* |
212 /* |
211 * If the "-processor" option is used, search the appropriate |
213 * If the "-processor" option is used, search the appropriate |
212 * path for the named class. Otherwise, use a service |
214 * path for the named class. Otherwise, use a service |
213 * provider mechanism to create the processor iterator. |
215 * provider mechanism to create the processor iterator. |
214 */ |
216 */ |
215 if (processorNames != null) { |
217 if (processorNames != null) { |
216 processorIterator = new NameProcessIterator(processorNames, processorCL, log); |
218 processorIterator = new NameProcessIterator(processorNames, processorClassLoader, log); |
217 } else { |
219 } else { |
218 processorIterator = new ServiceIterator(processorCL, log); |
220 processorIterator = new ServiceIterator(processorClassLoader, log); |
219 } |
221 } |
220 } catch (SecurityException e) { |
222 } catch (SecurityException e) { |
221 /* |
223 /* |
222 * A security exception will occur if we can't create a classloader. |
224 * A security exception will occur if we can't create a classloader. |
223 * Ignore the exception if, with hindsight, we didn't need it anyway |
225 * Ignore the exception if, with hindsight, we didn't need it anyway |
1017 } |
1019 } |
1018 |
1020 |
1019 /** |
1021 /** |
1020 * Free resources related to annotation processing. |
1022 * Free resources related to annotation processing. |
1021 */ |
1023 */ |
1022 public void close() { |
1024 public void close() throws IOException { |
1023 filer.close(); |
1025 filer.close(); |
1024 discoveredProcs = null; |
1026 discoveredProcs = null; |
|
1027 if (processorClassLoader != null && processorClassLoader instanceof Closeable) |
|
1028 ((Closeable) processorClassLoader).close(); |
1025 } |
1029 } |
1026 |
1030 |
1027 private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) { |
1031 private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) { |
1028 List<ClassSymbol> classes = List.nil(); |
1032 List<ClassSymbol> classes = List.nil(); |
1029 for (JCCompilationUnit unit : units) { |
1033 for (JCCompilationUnit unit : units) { |