This content has been marked as final. Show 1 reply
Milesy wrote:If you are naughty, you can try to find the file being processed and read it directly, but that is not supported.
Is it possible to access the source of the file being analysed at compile time?
You can use the javac-specific tree API (http://java.sun.com/javase/6/docs/jdk/api/javac/tree/index.html) to map from a javax.lang.model.Element to a AST representing the source for a method or constructor.
If you want the source for the purposes of modifying it, the annotation processing API is read-only, but much of the effect of mutating the source can be achieved by generating subclasses or the superclass of the class in question. Check the forum archives for details.