Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Obtain AST from JavaCompiler

843810Mar 14 2007 — edited May 11 2007
I would like to use the javax.tools API in jdk 6.0 to obtain the AST from a Java source file and then visit the AST. I'm pretty sure the class JavaCompiler and ClassTree can help me, but I have not been able to find any information (or examples) on how to do this, or work it out myself.

If someboby out there could give me some pointers that would be great (I'll continue on my own of course, and post the answer here once I find it).

I'm in the process of creating a Java to C compiler to run Java on our small embedded devices. I want to translate the Java source (not the class file) to C. Mostly for fun, but also because I think the result will be much more readable and compact than translating from bytescodes.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 8 2007
Added on Mar 14 2007
4 comments
491 views