OpenJDK parser internals

Dr Andrew John Hughes ahughes at redhat.com
Sun Sep 25 15:38:44 PDT 2011


On 23:27 Sun 25 Sep     , Steve S wrote:
> Hi All,
> 
> I'm just started deeply digging into OpenJDK sources (jdk6, langtools).
> The following strikes me as odd:
> 
> 1. Ast tree members (JCTree descendants) expose all theirs members in public
> access.
> Do I understand right that this is done due to: (1) simplicity, (2)
> performance gain?
> Is the option to rewrite it with final fields and getters ever considered?
> 
> 2. Lots of code with old-fashioned for-loop instead of for-each loop (e.g.
> iterating over internal linked List).
> 
> 3. Verbose exception handling approach - e.g. .tools.javac.tree.Pretty - all
> the visitor methods wraps implementation in try-catch block though it is
> sufficient to provide Pretty.print implementation that only wraps out.write
> to try-catch block with throwing UncheckedIOException.
> 
> 4... Lots of other stuff like code duplication, violation of encapsulation,
> etc.
> 
> Does someone have a "plan" to refactor this code? I never ever seen in the
> jdk7, 8 forks - may be it's worth it?
> Looks like it'd be a real pain due to lots of forks and would result in a
> outrageously complex merge.
> 
> ---
> Best Regards,
>     Alex

As a first suggestion, I'd look at the jdk8 code as that's where
active development takes place, specifically
http://hg.openjdk.java.net/jdk8/tl/langtools.  The OpenJDK6 code is
very outdated, with only a few backports since it was forked from
OpenJDK7 around b22.
-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and IcedTea
http://www.gnu.org/software/classpath
http://icedtea.classpath.org
PGP Key: F5862A37 (https://keys.indymedia.org/)
Fingerprint = EA30 D855 D50F 90CD F54D  0698 0713 C3ED F586 2A37



More information about the compiler-dev mailing list