Java 14 new features

You can follow the latest updates in Java here:

All the new features of every Java version:

Developer / language new features

These features are interesting for your daily basis activity.

Pattern matching for instanceof (Preview)

Here you can find an extended explanation. The pattern matching should be implemented initially for
instanceof, switch could follow in future releases.

Java 11 example:

if (obj instanceof String) { 
 String s = (String) obj; 

In this code we can see a 'pattern':

-> test: obj instanceof String

-> conversion: (String) obj;

-> assignment: String s = (String) obj;

-> usage: System.out.println(s);

Another issue is the repetition of String, it's used 3 times in this small example.

The pattern 'test -> conversion -> assignement -> usage' is a common pattern used by the developer.

With Java 14 we can simplify our code:

if (obj instanceof String obj) { 

If obj is an instance of String this is assigned to the String object obj.

You can find this feature already implemented in C#, Scala, Haskell

Records (Preview)


You can find a post with many details here:

Helpful NullPointerException

Switch Expression

Text Blocks (Second preview)

Garbage collector

If you want to know more about Garbage colletors in the JDK you can see my presentation here:

Z is coming to MacOS Z is already present as 'preview' feature for Linux 64-bit, now it is ported to MacOS and in future to Windows.

Z is the new powerful Garbage Collector developed by Oracle. This GC target Heaps until 1TB with pauses (stop-the-world) of max 10ms. Here you can find the details:
ZGC Wiki.

CMS (Concurrent Mark Sweep) removed

CMS is now removed from the sources, it was alredy deprecatd in Java 9.
CMS has been replaced G1, if you didn't migrate yet it's really time to do it.

G1, Parallel and Shenandoah are currently your best alternatives.

Deprecate the ParallelScavenge + SerialOld GC Combination

There is a lot going on in the GCs for Java. This combination has been replaced by Parallel GC and is not used frequently, for this reason will be deprecated.

Other improvements


Packaging (Incubator)

JDK Flight Recorder: JFR Event Streaming


Non-Volatile Mapped Byte Buffers

WebApp built by Marco using SpringBoot, Java 17, Mustache, Markdown and in Azure