Questions tagged [annotation-processing]

An annotation processor is a plug-in for the Java compiler. An annotation processor can do such things as analyze declarations, cause compilation errors and generate new compilation units.

An annotation processor is a plug-in for the Java compiler.

An annotation processor is an instance of javax.annotation.processing.Processor whose process method is invoked during compilation.

Once invoked, the processor is then able to do such things as:

  • Analyze parts of the abstract syntax tree, primarily declarations via javax.lang.model.element and types via javax.lang.model.type.
  • Cause compilation errors and warnings (similar to how the @Override annotation works) via the Messager.
  • Generate new compilation units (i.e. source code files) via the Filer which are subsequently compiled.

Notes on the current limitations of annotation processors

  • Annotation processors may only generate new compilation units, not modify existing compilation units. Some annotation processors, such as Project Lombok, achieve the latter via undocumented internal Javac API.
  • The existing API in Java Platform SE is limited to only analyzing declarations, such as class declarations and method declarations. The Compiler Tree API exists, which allows one to analyze the full abstract syntax tree, but it's largely undocumented and not yet a part of SE.

Resources

723 questions
-2
votes
1 answer

Annotation processor doesn't run

I wannna use annotation processor in my IDEA plugin, which will resolve classes and methods with 'TaskID' annotation. But I found that my processor can't run at all. I do wanna know what's wrong and what should I do. Here is my code below import…
-2
votes
1 answer

Get all classes that implement interface

I'm implementing an annotation processor that needs all classes that implement an interface. The main issue is that these classes can be anywhere, so there isn't an easy way to get them. I cannot edit this classes in any way. I need to get this…
kylie.zoltan
  • 377
  • 3
  • 15
-3
votes
1 answer

Run AnnotationProcessor after DataBinding Generation

I'm trying to make an annotation processor which takes an integer. It's working fine and all if I use explicit integer. But when I use value from android databinding BR class: @SomeAnnotation(BR.someField) It says that the BR class not found. I'd…
Fadli
  • 976
  • 9
  • 24
1 2 3
48
49