• Oracle JDK 14 adds new features to improve developer productivity, including Java language support for switch expressions, new APIs for continuous monitoring of JDK Flight Recorder data, and extended availability of the low-latency Z Garbage Collector to macOS and Windows
• This new release includes three preview features: Pattern Matching for instance of (JEP 305), Records (JEP 359) and Text Blocks (JEP 368)
Oracle recently announced the general availability of Java 14 (Oracle JDK 14). Java 14 continues Oracle’s commitment to accelerate innovation by delivering new enhancements to enterprises and the developer community with a new feature release every six months. 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 six-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.”
The Java 14 release is the result of industry-wide development involving open review, weekly builds, and extensive collaboration between Oracle engineers and members of the worldwide Java developer community via the OpenJDK Community and the Java Community Process.
The new features delivered in Java 14 include:
- JEP 305: Pattern Matching for instanceof (Preview) – This preview feature enhances Java with pattern matching for the instance of operator. This improves developer productivity by eliminating the need for common boilerplate code and allows more concise type-safe code.
- JEP 343: Packaging Tool (Incubator) – 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 tools is introduced in an incubator module, which is 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.
- JEP 345: NUMA-Aware Memory Allocation for G1 – Improves overall performance of the G1 garbage collector on non-uniform memory access (NUMA) systems.
- JEP 349: JFR Event Streaming – 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.
- JEP 352: Non-Volatile Mapped Byte Buffers – Adds a file mapping mode for the JDK when using non-volatile memory. The persistent nature of non-volatile memory changes various persistence and performance assumptions which are leveraged with this feature.
- JEP 358: Helpful NullPointerExceptions – Improves the usability of NullPointerExceptions by describing precisely which variable was null and other helpful information. This will increase developer productivity and improve the quality of many development and debugging tools.
- JEP 359: Records (Preview) – This preview feature provides a compact syntax for declaring classes which hold shallowly immutable data. This feature can greatly reduce boilerplate code in classes of this type, but the biggest benefit allowing the modeling of data as data. It should be easy, clear and concise to declare these shallowly-immutable nominal data aggregates.
- JEP 361: Switch Expressions (Standard) – This was a preview feature in JDK 12 and JDK 13 and is now being added as a standard feature. It allows switch to be used as either a statement or an expression. This feature simplifies every day coding and prepared the way for the pattern matching (JEP 305) feature previewed in this release.
- JEP 364: ZGC on macOS and JEP 365: ZGC on Windows – While most users that require ZGC also require the scalability of Linux-based environments, there are often needs for deployment and testing to support ZGC on macOS and Windows. There are also certain desktop applications targeting Windows and macOS which will benefit from ZGC.
- 368: Text Blocks (Second Preview) – 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 is being offered as a preview feature again in Java 14 with the goal of becoming standard in a future JDK release. Text Blocks make 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.
- 370: Foreign-Memory Access API (Incubator) – An API to allow Java programs to safely and efficiently access foreign memory outside of the Java heap.