This month we are focusing on Java 12 new features you should know about. In other articles, we looked at improvements to Garbage Collection, Java 12’s JVM Constants API explained in 5 minutes, Java 12 made microbenchmarking easier and Java 12 Switch Expressions explained in 5 minutes
In this article, we look at an overview of the main changes.
Java 12 is the March 2019 release of Java. It is a short-term release so will be superseded by a new Java in September. In this article, I will focus on the changes between Java 11 and Java 12. If you are upgrading from an earlier version of Java, I recommend you read our blog posts on Java 8, Java 9 and Java 10. So what issues will you find in upgrading from Java 11 to Java 12?
With any new release, there are new features and things which have changed…. So What is new?
There is only one new language change in Java 12, which is JEP 325: Switch Expressions. This makes the switch statement more flexible and is a ‘nice to have’ but not a major language change. We will be sticking to Java 8/Java 11 as the two versions of Java we use.
The way Java runs has changed. So, there are now better startup times on 64 bit systems thanks to JEP:341.
Garbage-collection in Java 12 is significantly improved with more options to fit different use cases. There are improvements to the traditional G1 Garbage collector and and a new Garbage collector called Shenandoah for users who want to have a low pause time – ie prioritise responsiveness on their systems. We have a detailed summary of the options in our post Changes to Garbage Collection in Java 12.
When we tested Java 12 on our systems, we also found that Maven would no longer accept a code base setting of Java 6 (you now need to be on Java 8). So if you are writing legacy code, you will need to stay on Java 11 or earlier.
In summary, Java 12 is probably not going to change the way you write Java, but it does simplify the development of the Java platform and offers some exciting options for optimisations with Garbage collection if you can run your code on the Java 12 JVM. You may well want to stay on Java 11 code level but start to run your code on there latest JVM to enjoy these benefits…
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.