We see in the following blog entry: http://blog.fogus.me/2011/07/21/compiling-clojure-to-javascript-pt1/ some pretty incredible syntax transformations, simplifications done to the javascript programming language, done by the Google Closure compiler.
My question is – is there something that provides these kinds of syntactic transformations for Java?
As a general rule, the Java compiler can/does some generally useful optimizations to produce JVM code. The JIT compiler in the JVM then does more optimizations as it generates native machine code. Since both of these are automatic and invisible to you, you don’t notice, but you don’t need to do them explicitly.
There are always transformations that might be done in the context of your program that the Java compiler and the JIT compiler cannot know to do. For these you ideally want to some kind of source-to-source program transformation system, which can read source code, parse it to some kind of tool-internal structure (typically ASTs), apply “incredible syntax transformations” that you define on this internal structure, and then regenerate source code in your language.
Our DMS Software Reengineering Toolkit (commercial) is such an engine; it handles many languages. DMS has a Java 1.6 front end which builds full symbol tables and provides control and data flow analyses, necessary to enable more complex transformations.
Free (university research) alternatives are Stratego and TXL, both of which have Java parsers of some (unknown to me) maturity, but definitely do not provide symbol tables or any kind of flow analysis, meaning you have to build these or a bad approximation yourself. There are folks that may suggest ANTLR, which also has a Java front end, probably builds ASTs, very likely does not build symbol tables, and doesn’t provide the rest of the machinery that typical transformation systems do (source-to-source transformations, regeneration of source text, etc.)
If you are happy with what the Java compiler does, you don’t need any of this. If it doesn’t do enough, then you want something like this. [The fact that you asked the question suggests you have some idea of something you want done that the Java compiler doesn’t do. Care to elaborate?]