News for hackers. Stuff that matters.

Ask HN: Parser for Java

I've done google searches, and generally get back Parser Generators in Java / how to write Parsers in Java.

What I want instead, is just a single industrial parser that can parse Java source code (like anything that the jvm can run). (Doing some really simple static analysis stuff).

Is there anything "official" that's easy to modify, like a parser from Sun or IBM or eclipse?

Thanks!

( 7 comments | 3 points | on HN )
Re:Ask HN: Parser for Java by scotth on Sunday July 26, 2009 @10:20PM (#725219)
I believe that one of the ANTLR examples (as provided in the source download), is a Java parser. http://www.antlr.org/
Re:Ask HN: Parser for Java by robdimarco on Sunday July 26, 2009 @08:41PM (#725115)
Are you looking for JavaCC? https://javacc.dev.java.net/
Re:Ask HN: Parser for Java by JimmyL on Monday July 27, 2009 @12:01AM (#725352)
>> industrial parser that can parse Java source code (like anything that the jvm can run)

Do you mean a parser for Java source code or bytecode? I would guess the former, but the reference to "anything that the jvm can run" suggests you may be looking for bytecode...

Re:Ask HN: Parser for Java by live_to_code on Monday July 27, 2009 @12:02AM (#725354)
Java source code.
Re:Ask HN: Parser for Java by adatta02 on Sunday July 26, 2009 @11:36PM (#725320)
Eclipse has the JDT package which gives you access to the parser that Eclipse uses internally.
Re:Ask HN: Parser for Java by live_to_code on Monday July 27, 2009 @12:02AM (#725353)
Ah; this is closest to what I want; though if I can use the Sun one Sun uses for javac, it'd be even better.
Re:Ask HN: Parser for Java by skybrian on Monday July 27, 2009 @02:05AM (#725460)
Yes, Javac is open source. You can't get any more official than that. http://openjdk.java.net/groups/compiler/