We are getting closer to the release of Java 10 and in this article, we are going to explore a couple of new interesting features that will be new in Java 10 OpenJDK.
Of course, as Java 10 has not been released yet, the following features might be subject to change. Additionally, new features might arrive last minute even though it’s unlikely as we are close to having a Release Candidate. But I will attempt to keep this article updated if something were to change.
Local-Variable Type Inference
Something that is new in Java 10 and perhaps the most interesting feature, at least from a coding perspective, is that the language attempts to improve the developer’s experience by removing some of the strict type safety. In Java 10 the language is not going to be as strict about type safety when working with local variables. As an example, the following code snippets will be perfectly valid.
var list = new ArrayList<String>();
var stream = list.stream();
var path = Paths.get(fileName);
var bytes = Files.readAllBytes(path);
The main motivation around it was that there has been quite a lot of complaints about all the boilerplate coding required in Java. In local variables, the argument for that strict type-safety increases read-ability doesn’t really apply as that is mostly achieved with a good naming of variables.
Garbage Collector Interface
New in Java 10 is the introduction of a clean garbage collector interface that aims to improve the isolation of source code of different garbage collectors. This has a couple of advantages such as, for example, making it easier to exclude a GC from a JDK build and making it easier to add a new GC without it affecting the code base.
Parallel Full GC for G1
In Java 9, G1 was made the default GC (Garbage Collector). Which was designed to avoid full collections, but when the concurrent collections couldn’t reclaim memory quick enough it would end up falling back on a full GC, and here is where the problem lies. The previous GC (prior to Java 9) supported parallel full GC, but in G1 up until now the full GC uses a single threaded mark-sweep-compact algorithm. Java 10 adds parallel full GC support to G1.
Heap Allocation on Alternative Memory Devices
NV-DIMM memory has become available cheaper lately which means that future systems often might be equipped with heterogeneous memory architectures. This new feature would, for example, make it possible in a multi-JVM environment to assign lower priority processes to use the NV-DIMM memory, and instead only allocate the higher priority processes to the DRAM.
Experimental Java-Based JIT Compiler
Also new in Java 10 is the enabling of Grool, a Java-based JIT compiler which is the basis of an experimental Ahead-of-Time (AOT) compiler. Grool was already added back in Java 9, but now it is possible to enable it with the following arguments.
However, keep in mind that it is in an experimental stage and definitely not recommended for production.
The cacerts in the JDK source code is empty in Java 9 which causes critical security components such as TLS to not work in default OpenJDK builds. Users had to workaround this by adding root certificates to the cacerts keystore. New in Java 10 is that the JDK provides a default set of root CA (Certification Authority) certificates.
Java 10 doesn’t perhaps come with the biggest and most game breaking changes, but it is the start of a new era of Java where we instead of once every 2-3 years get a new massive version, such as Java 8, we will now instead be provided with more regular but smaller updates. Which I, personally, believe is a good thing since it might entice enterprises to update more regularly instead of sticking to older legacy versions since there are too many changes in a new release. I might be completely wrong about this though, and it might have an opposite effect.
What is your opinion on this? Do you like these smaller but more regular updates, or do you prefer the older release system?