Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7338
| From | Sebastian <sebastian@undisclosed.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Using sun javac to parse java source |
| Date | 2011-08-24 10:51 +0200 |
| Organization | albasani.net |
| Message-ID | <j32e2d$jgg$1@news.albasani.net> (permalink) |
| References | <66227810-c927-4197-a138-f25b54f26f7f@k8g2000yqk.googlegroups.com> <4e543134$0$305$14726298@news.sunsite.dk> |
Am 24.08.2011 01:00, schrieb Arne Vajhøj: > On 8/23/2011 4:24 PM, Alex J wrote: >> I'm curious whether it is possible to use JavacParser - >> http://docjar.org/docs/api/com/sun/tools/javac/parser/JavacParser.html >> - built-in to OpenJDK to parse standalone java files (though claimed >> to be "internal use only API"). I googled but I've found no answers. > > Java 1.6 and newer contains a supported callable Java compiler. > > Use that. > > If you only want to syntax check you will need to discard the > generated byte code in case of success, but that is easy. > > The API is a bit complex many would say over engineered, but > it works fine. > > Arne > > You might find a detailed example useful. There is an article about "Dynamic Code Generation with Java Compiler API in Java 6" by Swaminathan Bhaskar at http://www.scribd.com/doc/56642760/Java-Compiler The article shows how to compile source from strings to byte arrays. -- Sebastian
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Using sun javac to parse java source Alex J <vstrength@gmail.com> - 2011-08-23 13:24 -0700
Re: Using sun javac to parse java source Arne Vajhøj <arne@vajhoej.dk> - 2011-08-23 19:00 -0400
Re: Using sun javac to parse java source Lew <lewbloch@gmail.com> - 2011-08-23 17:25 -0700
Re: Using sun javac to parse java source Arne Vajhøj <arne@vajhoej.dk> - 2011-08-23 21:52 -0400
Re: Using sun javac to parse java source Lew <lewbloch@gmail.com> - 2011-08-23 20:20 -0700
Re: Using sun javac to parse java source Arne Vajhøj <arne@vajhoej.dk> - 2011-08-24 19:22 -0400
Re: Using sun javac to parse java source Lew <lewbloch@gmail.com> - 2011-08-24 21:05 -0700
Re: Using sun javac to parse java source Sebastian <sebastian@undisclosed.invalid> - 2011-08-24 10:51 +0200
Re: Using sun javac to parse java source Arne Vajhøj <arne@vajhoej.dk> - 2011-08-24 19:19 -0400
csiph-web