Java 14 debuted on March 17, the first major update of the Java programming language in 2020.
Java 14 comes six months after the September 2019 release of Java 13, keeping with Oracle's plan to deliver at least two major Java updates a year. Among the new features in Java 14 are capabilities to improve developer productivity and code visibility and to enhance overall performance.
One of the new features, Java Enhancement Proposal 361 (JEP 361), makes Switch Expressions a standard feature in Java. Performance, meanwhile, is getting a boost via JEP 345 for NUMA-Aware Memory Allocation for the Java G1 garbage collector.
Java Flight Recorder Event Streaming
A key part of the Java Development Kit is the Java Flight Recorder (JFR) feature, which provides a tool to help profile Java applications for diagnostic purposes. In Java 14, Java Flight Recorder gains a new streaming data capability.
"JFR Event Streaming (JEP 349) is a new feature in Java 14 that I think people will be able to use right away," Georges Saab, vice president of development for the Java Platform at Oracle, told ITPro Today. "That changes the historical way that Java Flight Recorder data has been consumed, which is kind of in batch format, to now being available as sort of a stream of events that you can deal with in real time."
JFR Event Streaming is useful for anywhere that a Java Virtual Machine (JVM) is running, whether that's on-premises or in the cloud, according to Saab. He added that the new feature will help developers more easily figure out what's going on at application runtime as a program executes.
Another new feature in Java 14 is JEP 358 for Helpful NullPointerExceptions. A null pointer exception is a common type of coding flaw in which a pointer in the code does not point to a valid variable.
"It's about people being able to figure out when they run into a null pointer exception that they know exactly where they come from and how can they deal with it quickly and more effectively," Saab said.
Java 15 and Beyond
Java 14 also includes a number of features that will be in preview or incubation phase until they are mature enough for full standard availability. One such feature is the Packaging Tool (JEP 343), which is now in the incubation phase.
The packaging tool helps developers create self-contained Java applications. Rather than having separate delivery of a runtime like the Java Runtime Environment (JRE) from the application code that a developer might provide, JEP 343 gives people a way of packaging all of that together, Saab said.
"So, you can use jlink in order to create a slimmed-down runtime that is custom just for your application that includes only what your application needs," he said. "Then use the packaging tool to put that together into a format that can be delivered as a unit."