Class AbstractProcessor
- All Implemented Interfaces:
Processor
public abstract class AbstractProcessor extends Object implements Processor
The getter methods may issue warnings about noteworthy conditions using the facilities available after the processor has been initialized.
Subclasses are free to override the implementation and specification of any of the methods in this class as long as the general Processor contract for that method is obeyed.
- Since:
- 1.6
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
protected ProcessingEnvironment |
processingEnv |
Processing environment providing by the tool framework. |
Constructor Summary
| Modifier | Constructor | Description |
|---|---|---|
protected |
Constructor for subclasses to call. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
Iterable |
getCompletions |
Returns an empty iterable of completions. |
Set |
getSupportedAnnotationTypes() |
Returns the names of the annotation interfaces supported by this processor. |
Set |
getSupportedOptions() |
Returns the options recognized by this processor. |
SourceVersion |
getSupportedSourceVersion() |
Returns the latest source version supported by this annotation processor. |
void |
init |
Initializes the processor with the processing environment. |
protected boolean |
isInitialized() |
|
abstract boolean |
process |
Processes a set of annotation interfaces on root elements originating from the prior round and returns whether or not these annotation interfaces are claimed by this processor. |
Field Details
processingEnv
protected ProcessingEnvironment processingEnv
Constructor Details
AbstractProcessor
protected AbstractProcessor()
Method Details
getSupportedOptions
public Set<String> getSupportedOptions()
- Specified by:
-
getSupportedOptionsin interfaceProcessor - Implementation Requirements:
- If the processor class is annotated with
SupportedOptions, return an unmodifiable set with the same set of strings as the annotation. If the class is not so annotated, an empty set is returned. - Returns:
- the options recognized by this processor, or an empty set if none
- See Also:
getSupportedAnnotationTypes
public Set<String> getSupportedAnnotationTypes()
- Specified by:
-
getSupportedAnnotationTypesin interfaceProcessor - Implementation Requirements:
- If the processor class is annotated with
SupportedAnnotationTypes, return an unmodifiable set with the same set of strings as the annotation. If the class is not so annotated, an empty set is returned. If the source version does not support modules, in other words if it is less than or equal toRELEASE_8, then any leading module prefixes are stripped from the names. - Returns:
- the names of the annotation interfaces supported by this processor or an empty set if none
- See Also:
getSupportedSourceVersion
public SourceVersion getSupportedSourceVersion()
- Specified by:
-
getSupportedSourceVersionin interfaceProcessor - Implementation Requirements:
- If the processor class is annotated with
SupportedSourceVersion, return the source version in the annotation. If the class is not so annotated,SourceVersion.RELEASE_6is returned. - Returns:
- the latest source version supported by this annotation processor
- See Also:
init
public void init(ProcessingEnvironment processingEnv)
- Specified by:
-
initin interfaceProcessor - Implementation Requirements:
- Initializes the processor with the processing environment by setting the
processingEnvfield to the value of theprocessingEnvargument. AnIllegalStateExceptionwill be thrown if this method is called more than once on the same object. - Parameters:
-
processingEnv- environment to access facilities the tool framework provides to the processor - Throws:
-
IllegalStateException- if this method is called more than once.
process
public abstract boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
true is returned, the annotation interfaces are claimed and subsequent processors will not be asked to process them; if false is returned, the annotation interfaces are unclaimed and subsequent processors may be asked to process them. A processor may always return the same boolean value or may vary the result based on its own chosen criteria. The input set will be empty if the processor supports
"*" and the root elements have no annotations. A
Processor must gracefully handle an empty set of annotations.
getCompletions
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
- Specified by:
-
getCompletionsin interfaceProcessor - Parameters:
-
element- the element being annotated -
annotation- the (perhaps partial) annotation being applied to the element -
member- the annotation member to return possible completions for -
userText- source code text to be completed - Returns:
- an empty iterable of completions
isInitialized
protected boolean isInitialized()
- Returns:
-
trueif this object has been initialized,falseotherwise
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.compiler/javax/annotation/processing/AbstractProcessor.html