- All Implemented Interfaces:
Type processing occurs in one round after the tool (e.g. Java compiler) analyzes the source (all sources taken as input to the tool and sources generated by other annotation processors).
The tool infrastructure will interact with classes extending this abstract class as follows.
1-3 are identical to the
Processor life cycle. 4-5 are unique to
- If an existing
Processorobject is not being used, to create an instance of a processor the tool calls the no-arg constructor of the processor class.
- Next, the tool calls the
initmethod with an appropriate
- Afterwards, the tool calls
getSupportedSourceVersion. These methods are only called once per run, not on each round.
- For each class containing a supported annotation, the tool calls
typeProcessmethod on the
Processor. The class is guaranteed to be type-checked Java code and all the tree type and symbol information is resolved.
- Finally, the tool calls the
typeProcessingOvermethod on the
The tool is permitted to ask type processors to process a class once it is analyzed before the
rest of classes are analyzed. The tool is also permitted to stop type processing immediately if
any errors are raised, without invoking
A subclass may override any of the methods in this class, as long as the general
Processor contract is obeyed, with one notable exception.
process(Set, RoundEnvironment) may not be overridden, as it is called during the
declaration annotation phase before classes are analyzed.
protectedConstructor for subclasses to call.
Method SummaryModifier and TypeMethodDescription
com.sun.tools.javac.util.LogReturn the compiler log, which contains errors and warnings.
final booleanThe use of this method is obsolete in type processors.
abstract voidProcesses a fully-analyzed class that contains a supported annotation (see
voidA method to be called once all the classes are processed.
voidA method to be called once before the first call to typeProcess.
Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, isInitialized
AbstractTypeProcessorprotected AbstractTypeProcessor()Constructor for subclasses to call.
initpublic void init
Register a TaskListener that will get called after FLOW.
processThe use of this method is obsolete in type processors. The method is called during declaration annotation processing phase only. It registers the names of elements to process.
typeProcessingStartpublic void typeProcessingStart()A method to be called once before the first call to typeProcess.
Subclasses may override this method to do any initialization work.
typeProcesspublic abstract void typeProcess
(TypeElement element, com.sun.source.util.TreePath tree)Processes a fully-analyzed class that contains a supported annotation (see
The passed class is always valid type-checked Java code.
element- element of the analyzed class
tree- the tree path to the element, with the leaf being a
typeProcessingOverpublic void typeProcessingOver()A method to be called once all the classes are processed.
Subclasses may override this method to do any aggregate analysis (e.g. generate report, persistence) or resource deallocation.
getCompilerLog()can be used to access the number of compiler errors.
getCompilerLog@SideEffectFree public com.sun.tools.javac.util.Log getCompilerLog()Return the compiler log, which contains errors and warnings.
- the compiler log, which contains errors and warnings