JDK 14: The new features in Java 14

Switch expressions and NVM-supporting file mapping byte buffers are slated for the next version of standard Java due in 2020

Here are descriptions of the features expected to be targeted in JDK 14 thus far:

  • The planned improvement to NullPointerExceptions pertains to improving the usability of the exceptions generated by the JVM by describing exactly which variable was null. Authors of the proposal are looking to provide helpful information to developers and support staff about the premature termination of a program and improve program understanding by more clearly associating a dynamic exception with static program code. One goal is to reduce confusion and concern developers have about NullPointerExceptions.
  • Non-volatile mapped byte buffers would add new JDK-specific file mapping modes that allow the FileChannel API to be used to create MappedByteBuffer instances that refer to non-volatile memory (NVM). NVM enables programmers to build and update program state across program runs without incurring the significant copying or translation costs that input and output operations usually require. This is particularly significant for transactional programs. Thus the chief goal of this JDK Enhancement Proposal is to ensure that clients can access and update NVM from a Java program coherently and efficiently. A secondary goal is to implement this commit behavior using a restricted, JDK-internal API defined in class Unsafe, so it can be re-used by classes other than MappedByteBuffer that may need to commit to NVM. Another goal is to allow buffers mapped over NVM to be tracked by existing APIs for monitoring and management. Target OS/CPU platforms include Linux/x64 and Linux/AArch64.
  • Switch expressions simplify coding by extending switch so that it can be used as either a statement or an expression. Switch expressions are expected to be a permanent feature in JDK 14, after being previewed in both JDK 12 and JDK 13. Switch expressions also prepare for the use of pattern matching in switch, which will allow developers to conditionally extract components from objects more concisely and safely. 

Where to download JDK 14 beta builds

You can download open source JDK 14 beta builds from jdk.java.net for Linux, Windows, and MacOS.

To continue reading this article register now