The latest Java Development Kit (JDK) delivers new features, including two new highly anticipated preview features—Pattern Matching for instance of (JEP 305) and Records (JEP 359), as well as a second preview of Text Blocks (JEP 368). Additionally, the latest Java release adds Java language support for switch expressions, exposes new APIs for continuous monitoring of JDK Flight Recorder data, extends the availability of the low-latency Z Garbage Collector to macOS and Windows, and adds, in incubator modules, the packaging of self-contained Java applications and a new Foreign memory access API for safe, efficient access to memory outside of the Java heap.
“Java 14 is further validation of the benefits of the 6-month release cadence, giving developers access to features that they would otherwise be waiting years to get their hands on,” said Georges Saab, vice president of development, Java Platform, Oracle. “Not only does JDK 14 have a number of enhancements that will improve developer productivity, but we’re also seeing the first major content to come from projects like Project Panama, with a Foreign-Memory Access API enhancement (JEP 370), and continuing improvements from Project Amber, with Pattern Matching (JEP 305) and Records (JEP 359). These significant enhancements are testament to all of the hard work in these groundbreaking projects.”
Pattern Matching for instanceof (JEP 305) is a preview feature that enhances Java with pattern matching for the instanceof operator. This improves developer productivity by eliminating the need for common boiler plate code and allows more concise type-safe code.
Additionally, Packaging Tool (JEP 343) provides a way for developers to package Java applications for distribution in platform-specific formats. This helps developers with modern applications where constraints require runtimes and applications to be bundled in a single deliverable. This tool is introduced in an incubator module, as a way of putting non-final APIs and non-final tools in the hands of developers to get their feedback while the APIs/tools progress towards either finalization or removal in a future release.
NUMA-Aware Memory Allocation for G1 (JEP 345) improves overall performance of the G1 garbage collector on non-uniform memory access (NUMA) systems and JFR Event Streaming (JEP 349) exposes JDK Flight Recorder (JFR) data for continuous monitoring. This will simplify access to JFR data for various tools and applications and spur further innovation.
After receiving end-user feedback when Text Blocks was first introduced as a preview feature as part of Java 13, enhancements have been added and Text Blocks (368) is being offered as a preview feature again in Java 14 with the goal of becoming standard in a future JDK release. Text Blocks is a feature that makes it easy to express strings that span several lines of source code. It enhances the readability of strings in Java programs that denote code written in non-Java languages; it supports the migration from string literals by stipulating that any new construct can express the same set of strings as a string literal, interpret the same escape sequences and be manipulated in the same ways as a string literal.
More information about other Oracle OpenJDK 14 features can be found at https://openjdk.java.net/projects/jdk/14.