Why the annotation processing API ?

Stéphane NICOLAS steff.nicolas at gmail.com
Thu May 26 04:32:38 UTC 2016

Hi folks,

I know a simple mail like this generally has very minimal value. But still,
it's been around 2-3 years now that I work on Android, doing a lot of work
around reflection and annotation processing.

I don't like the annotation processing API. I still find every concept hard
to remember, and it is always taking time to get immersed into it for a new

Thus, I don't understand, very humbly and very honestly, why this API even
exists. Why can't we simply use reflection-like APIs ? It would not be that
complex to expose an API that looks like reflection (read-only of course,
no new instance of classes, to method calls or setting/getting field
values, just the discovery part).

I could see over the past years that the newer versions of the JDK are
aligning more and more the capacities of the annotation processing API with
reflection APIs. Some subtle changes but always in this direction. All you
can do with reflection is now possible with annotation processing
(read-only still, as stated above).

Does it sound completely stupid to ask that javac annotation processor API
for JDK 10 would actually match reflection API ? Reflection API is so
simple and it describes OO code in a natural way for all java coders.
Methods, classes, fields... much simpler than an element type with a kind
that you can cast into I don't know what ! Annotation processing API is not
clear. It is obviously overworked, complex, abstract, very scholar and hard
to use.

Is there anything that can be done with respect to this problem ?
I hope I am not saying something completely dumb here, but I have been
thinking about this for a very long time now.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20160525/6255a9ba/attachment.html>

More information about the compiler-dev mailing list