Obtain AST from JavaCompiler
843810Mar 14 2007 — edited May 11 2007I 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.