10 new features in java 10!

Java 10 is around the corner! and if java 9 took forever to be released, Oracle seems to be respecting the schedule this time and java 10 will be publicly released soon!
In this article, will explore 10 features coming to this new update for java.

1. JEP 286: 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 declaration, allowing developers to let the compiler infer the type by only using var. In Java 10 the language is not going to be as strict about type safety when working with local variables. This will allow declarations such as:

var list = new ArrayList<String>(); // infers ArrayList<String>  
var stream = list.stream(); // infers Stream<String>  

You can find more details here.

2. JEP 322: Time-Based Release Versioning

This JEP talks about revising the version string scheme of the Java SE Platform and the JDK, as well as the related versioning information, for present and future time-based release models for some needed clarifications, with a six-month release model.

So the March 2018 release will be named JDK 10, September 2018 release will be named JDK 11 and so on. The Update element will increment one month after the Feature element is incremented, so the April 2018 Java release will be JDK 10.0.1, July 2018 release will be named JDK 10.0.2 and so on.

3. JEP 304: Garbage-Collector Interface

This JEP increases code isolation of different garbage collectors and introduces a clean interface for 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.

4. JEP 307: Parallel Full GC for G1

In Java 9, G1 was made the default GC, 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 aim of JEP 307 is to parallelize the full GC algorithm so that in the unlikely event of a G1 Full GC then the same number of threads can be used as in the concurrent collections.

5. JEP 316: Heap Allocation on Alternative Memory Devices

This JEP enables the HotSpot VM to allocate the Java object heap on an alternative memory device, specified by the user. 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.

6. JEP 296: Consolidate the JDK Forest into a Single Repository

Nothing much to say about this JEP aside the fact that it's all about housekeeping. It will combine the numerous repositories of the JDK forest into a single repository.

7. JEP 319: Root Certificates

JEP 319 will provide a default set of root Certification Authority making OpenJDK builds more appealing to developers. It also aims to reduce the difference between the OpenJDK and Oracle JDK builds. Critical security components such as TLS will now work by default in OpenJDK builds.

8. JEP 317: Experimental Java-Based JIT Compiler

This JEP introduces the Graal compiler research project to the JDK. A new Java-based JIT compiler which is the basis of an experimental Ahead-of-Time (AOT) compiler. Graal was already added back in Java 9, but now it is possible to enable it with the following arguments.

-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler

However, keep in mind that it is in an experimental stage and definitely not recommended for production.

9. JEP 312: Thread-Local Handshakes

This JEP lays the groundwork for improved VM performance, by making it possible to execute a callback on application threads without performing a global VM safepoint. This would mean that the JVM could stop individual threads and not just all of them. Some of the small, low-level improvements that this will enable include:

  • Reducing the impact of acquiring a stack trace sample (e.g. for profiling)
  • Better stack trace sampling by reducing reliance on signals.
  • Improving biased locking by only stopping individual threads for revoking biases.
  • Removing some memory barriers from the JVM

10. JEP 313: Remove the Native-Header Generation Tool

Following the effort of housekeeping the jdk, java 10 will no longer have a separate tool to generate header files when compiling JNI code, as this can be done through javac. This JEP removes the javah tool from the JDK.

Final words

Overall, it seems that Java 10 is unlikely to contain any major new features or performance improvements. This is perhaps to be expected - instead of vast change, it represents the first release in the new, more frequent and gradual release cycle.


Update: I mistakenly used type safety while my intention was type declaration. Thanks David for highlighting this ;) (comment)