Java annotation processing (since Java 6) is a very good concept, because it allows to access lots of information about classes and methods through the Element
interface (and others).
But sadly, I had to find out empirically, that non-annotated classes are never passed to a custom annotation processor:
warning: No SupportedAnnotationTypes annotation found on
my.TESTProcessor, returning an empty 开发者_如何学编程set.
Are my findings true? Or can I "trick" the compiler to give my custom annotation processor information about non-annotated classes as well?
Great!
This gives me really all classes, not just annotated ones:
@SupportedAnnotationTypes("*")
The spec of that anotation says:
[...] Finally, "*" by itself represents the set of all annotation types,
including the empty set. Note that a processor should not claim "*"
unless it is actually processing all files [...]
Tested, works!
精彩评论