에서 메소드 본문을 얻는 방법, 내가 만든 : 이 좀 주석이 클래스의 모든 방법을 얻을 수 있어요 내 <code>AbstractProcessor</code>에서 ExecutableElement
List<? extends Element> allElements = processingEnv.getElementUtils().getAllMembers((TypeElement) bean);
List<ExecutableElement> methods = ElementFilter.methodsIn(allElements);
인가
이 방법의 몸을 얻을 수 있습니다/ExecutableElement
? API는 서명 및 수정 자만 처리하는 것 같습니다.
아마이 답변의 일부 변화 사용할 수
:. 독점 * .sun에서 액세스 클래스, https://stackoverflow.com/a/34568708/6095334을 ** 패키지 등 com.sun.tools.javac.tree.JCTree$MethodTree
같은 : trees
는 com.sun.source.util.Trees
세트의 인스턴스입니다
MethodTree methodTree = trees.getTree(executableElement);
AbstractProcessor의 init() 메소드는 다음과 같습니다 : trees = Trees.instance(processingEnv);
그러나이 클래스에는 경고 메시지가 있습니다 : 이것은 지원되는 API의 일부가 아닙니다. 이것에 의존하는 코드를 작성하면, 스스로 위험을 감수해야합니다. 이 코드와 내부 인터페이스는 사전 통보없이 변경되거나 삭제 될 수 있습니다.
좀 더 일반적인 주석 처리 프레임 워크에서 주석 처리 된 메소드의 본문에 액세스 할 수 있었으면 좋겠습니다.