| FAQ annotation processing in eclipse |
![]() |
| Frequently Asked Questions | |
Annotations are a simple metadata facility added to the Java language. Annotations can be
used anywhere a modifier can be used, like
public class Foo {
@Override
public int hashCode() {
return super.hashCode() ^ 1;
}
}
This indicates that the method hashCode must override a method
with the same signature in its superclass. If the method name were spelled wrong, a
processor could notice this and issue an error.
Standard uses for annotation processors include EJB and Web Services generators. Additional information on annotations can be found in the Java documentation here.
Java 5 added annotation to the core language.
We hook into the JDT compiler. If an annotation is detected, we dispatch to any processors that claim that annotation. We then provide an implementation of the mirror APIs over the JDT typesystem. If a processor creates a new source file, we then call the necessary JDT APIs to perform compilation on that new file.
Yes! This is one of the major goals of the jdt-apt project: you should be able to use an existing processor directly inside of eclipse and get an interactive experience, provided your processor is reasonably quick and efficient.
No. They're treated just like any other error.
Yes. When you create your error markers via the Messager API, downcast to EclipseMessager, and use the printFixable...() APIs. These error markers can then be processed with a QuickFixProcessor via the JDT APIs in Eclipse.
|