In my AbstractProcessor I am able to get all methods from a class annotated with some annotation, I have created:
List<? extends Element> allElements = processingEnv.getElementUtils().getAllMembers((TypeElement) bean);
List<ExecutableElement> methods = ElementFilter.methodsIn(allElements);
Is is possible to get the body of the method/ExecutableElement? The API only seem to deal with the signature and modifiers.
I could probably use some variation of this answer: https://stackoverflow.com/a/34568708/6095334, to access classes from the proprietary *.sun.** package, such as com.sun.tools.javac.tree.JCTree$MethodTree:
MethodTree methodTree = trees.getTree(executableElement);
where trees is an instance of com.sun.source.util.Trees set in the AbstractProcessor's init() method as so: trees = Trees.instance(processingEnv);
But these classes come with a warning: This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
I would hope that it was possible to access an annotated method's body from within the more general annotation processing framework.