Annotation processors are excellent feature of JDK6 which turn the Java languge into almost perfect language to implement internal DSLs (as the live database demo shows).

However the AnnotationProcessor API was not designed with incremental compilation in mind and integrating it into NetBeans IDE is not trivial. The Java support in the IDE tries to reparse as small piece of the source as possible, but sometimes, even a small change can have huge impact on the result of the processing. Depending on what the annotation processor does, the IDE needs to invoke it differently.

NetBeans AnnotationProcessor API Extensions

NetBeans offer a way to annotate the AnnotationProcessor with additional annotation (needs to have Retention.RUNTIME) to tell the system that:

  1. an annotation processor shall not be executed at all
  2. an annotation processor operates on classes in one package
  3. an annotation processor operates on all sources in the project
  4. an annotation processor is influenced by non-signature changes in the source

The @NbBundle.Messages AnnotationProcessor will classify itself as one that operates on files in a whole package. That will slow things down, but only when the actual annotation is used (e.g. apisupport modules only). Regular usages of common annotations will stay unaffected.

tzezula: There can be another way of registration than annotation, for example layer and property. The 4th option is needed by Lombok's val. I doubt that Lombok AP will be annotated by such a runtime annotation, so we will need some additional way of registration.

tzezula: What to do when APs are enabled in the editor? The only possibility is not to run mode 2 and mode 3 APs in the editor because of performance reasons. Such APs will run only during index (save).


The annotations with defined simple names (the fully qualified names are not important) will be defined for such a purpose. The JavaCustomIndexer and APTUtil will use them to disable the annotation processor or to extend the list of files to be (re)indexed.

@ServiceProvider(service = Processor.class)
public class NbBundleProcessor extends AbstractProcessor {
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo