Frequently Asked Questions

  1. What are annotations?

    Annotations are a simple metadata facility added to the Java language. Annotations can be used anywhere a modifier can be used, like public, static, and final. These annotations can be used at build or run-time in myriad ways. Here's an example annotation:

    public class Foo {
      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.

  2. When were annotations added to the Java language?

    Java 5 added annotation to the core language.

  3. How does jdt-apt extend basic JDT support?

    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.

  4. Can I use an existing processor I wrote for the commandline "apt" tool inside of eclipse?

    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.

  5. Are the errors from my processor different from other JDT errors?

    No. They're treated just like any other error.

  6. Can I get quick-fixes inside annotation values?

    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.