Thursday 11th September, 2014
2:20pm to 3:20pm
As Java developers we can learn a lot by studying the compiler. It is very interesting to see what happens to our code on the way to become byte codes.
Contrary to what you may believe, the compiler is in fact surprisingly easy to understand. The compilation process is intuitive, with clearly defined stages: lexing, parsing, attribution, flow analysis, desugaring and finally byte code generation. Each step will be presented with familiar examples that Java developers experience in their everyday work.
Adding goto syntax follows the same step-by-step process, hooking into the relevant stages along the way. The changes can be done incrementally with supporting unit tests to assert the sanity of the compiler.
The example is particularly attractive and educational, as all the required components are readily part of the language: reserved goto word, labeled statements and byte code. A radical change to the language can therefore be achieved with only a tiny effort. This shows how extensible the Java language and virtual machine can be.
Compilation of lambda statements is a particularly interesting new feature. We will look into how this is solved by the compiler, and play with a small naive change to also target earlier releases of the JVM.
Let us demystify the compiler and in a playful manner see what we can do with it!
Sign in to add slides, notes or videos to this session