Feb 04

I was going to implement my @WeakReference, I really was! However, the current apt tool doesn’t really cut it.

For example, it doesn’t seem to allow for processing inside code portions, only on declarations such as method declarations and class declarations. Another annoyance is with the way the apt API is supplied: The annotation processing API and mirror API are both in some com.sun.mirror.* package. Last but not least, there is no ant task for apt processing. This ensures a headache when creating build scripts.

That said, I am not sure the new API will allow me to implement my @WeakReference still, as I need my annotation processor be called for every instance of a previously annotated field/variable declaration. As far as I understand, currently only the declaration itself is called upon.

Some cute new features in the JSR 269 include easier annotation processor writing: Instead of writing a factory and a processor, such as in the current tool, you just write your processor and annotate it with whatever the factory would have returned.

This does not break the type safety the interface provides, as the annotatiosn are used to determine what values are returned from the factory’s interface methods. You can compare code examples of the old and of the new.

Another thing to take note is that annotation processing does not take place in an external tool such as apt, but are now done as part of javac‘s work. This solves the ant task, I suppose.

Related Posts with Thumbnails
Share

One Response to “Annotation Processing, then and tomorrow”

  1. Renaud Says:

    Hi! You should take a look at Spoon (http://spoon.gforge.inria.fr/). It seems to fit your needs (at least it allows processing *inside* method bodies)…