Is it possible to access the Abstract Syntax Tree(AST) inside the javac.exe programmatically? Could you provide an example?
Is it possible to access the Abstract Syntax Tree(AST) inside the javac.exe programmatically? Could
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, it is possible, but only since Java 6. Peter von der Ahé talks about the two JSRs in this interview. Of JSR 199:
JSR 269 is the annotation processing API.
This article gives an excellent overview of accessing the Compiler Tree API. The section ‘Accessing the Abstract Syntax Tree: The Compiler Tree API‘ seems particularly suitable for your question.
Depending on what you’re doing, you may also want to look at the Jackpot Rule Language, which is a standalone refactoring engine that plugins into the Compiler Tree.