How «final» is final?
This talk will show the different aspects of «finality» and their impact on the Java compiler and the JVM.
Although the concept of «final» fields is quite simple, its implementation in Java can lead to surprising effects. First of all, the Java VM and Java language have a slightly different understanding of "final". Second (and unfortunately) declaring a field as final doesn’t mean that the VM or the programmer can really rely on its immutability.
This talk will show the different aspects of "finality" and their impact on the Java compiler and the Java VM. It will demonstrate how finality can be circumvented in Java with the help of reflection or sun.misc.Unsafe. And finally it will discuss the impacts this has on the optimizations done by the JIT compiler and various workarounds like the non-standard @Stable annotation or -XX:TrustFinalNonStaticFields.