Java 12: a sneak peek at the new features - Questers

Java 12: a sneak peek at the new features

A new set of Java updates is on its way and we are very excited about it. The Release candidate of Java 12 has been live since the beginning of February and we are just a day away from the official release. So, while waiting, we’ve decided to take a look at the new features over a good cup of coffee.

JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector

The new version introduces experimental garbage collector called Shenandoah, an open-source low-pause time collector for OpenJDK. Its aim is to provide predictable and short GC pauses whether the heap is 200 MB or 200 GB.

JEP 230: Microbenchmark Suite

The upcoming release adds a new Microbenchmark suite to the JDK source code.  Its aim is to ease developers to run existing microbenchmarks and create new ones. This will be achieved by co-locating the microbenchmark suite with the source code in a single directory and by that simplifying the process of adding and locating benchmarks during development.

JEP 325: Switch Expressions

That feature provides an extension of the Switch statement so that it can be used as either a statement or an expression and therefore have a value or return one. Moreover, both forms would be able to use either a “traditional” or “simplified” scoping and control flow behaviour. The main purpose of this feature is once again to ease the developers and simplify the everyday coding.

334:    JVM Constants API

This improvement suggests an API modelling the key-class file and run-time artifacts. Such API would contain classes like ClassDesc, MethodTypeDesc, MethodHandleDesc, and DynamicConstantDesc. This feature would be useful for tools manipulating the classes and methods.

JEP 340: One AArch64 Port, Not Two

Currently, there are two 64-bit ARM ports (arm64 and aarch64) in the JDK. In Java 12 all sources related to arm64 port would be removed retaining the 64-bit aarch64 port. This would allow contributors to focus on a single 64-bit ARM implementation and would prevent the duplicate work to maintain two ports.

JEP 341: Default CDS Archives

In Java 12 the JDK build process would be enhanced to generate class data-sharing (CDS) archive by using the default class list on 64-bit platforms. The implementation of CDS archives is aiming to reduce startup time and benefit from memory sharing.

JEP 344: Abortable Mixed Collections for G1

This improvement aims to make G1 mixed collections abortable if they exceed the pause target. This will be achieved by splitting the collection set into two parts – a mandatory one, that compares parts of the collection set that G1 cannot process incrementally (e.g., the young regions), and an optional one, that consist of only old regions. After G1 completes the collection of the mandatory part, it starts the collection of the optional part at a much more granular level, but only if there is time left.

JEP 346: Promptly Return Unused Committed Memory from G1

Currently, G1 garbage collector only returns memory from the Java heap at either a full GC or during a concurrent cycle. The update will enhance the G1 garbage collector to automatically return Java heap to the operating system when idle.

Java 12 seems to be coming with a number of great improvements, making the programming language even faster and more efficient. Are you excited about the upcoming release? While waiting check out the open positions we have for passionate and innovative Java professionals.