Javac Tree API suggestions to more closely model source code

Martin Buchholz martinrb at
Tue Sep 30 16:44:22 UTC 2014

Just a few meta-comments:

As popularized by the Go folk, programming language styles are moving in
the direction of automatic reformatting, especially of whitespace,   If
done well, it's very valuable, freeing the programmer from having to worry
about the formatting.  But it's very hard for the program to do as well as
a careful programmer doing source code layout, reminiscent of the ancient
debate of assembly language programmers vs. "high-level" languages like C.

The hardest thing to get right is comments (this is the experience of the
Go folk).  Comments often refer to some other part of the AST.  javadoc
comments refer to the subsequent program element, end-of-line comments
typically refer to the preceding code on the same line (which may not
correspond to a single AST node), and other comments may refer to a
"section" of subsequent program elements, e.g.

// --------------- Constructors ------

One consequence of moving to automated formatting may be a need to
introduce new comment types, as with the distinction between /* and /** to
communicate intent to the formatter.

Although Harry is currently focused on whitespace only, a natural direction
is to unconditionally reorder any modifiers encountered into canonical
order, as mandated by some existing java coding styles.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list