Switch expressions and NVM-supporting file mapping byte buffers are slated for the next version of standard Java due in 2020
Java 13 only just shipped September 17, but work has already begun on its successor, Java 14. One official feature has already been set and another will likely be made official soon.
Oracle on September 17 said switch expressions are expected to go final in Java Development Kit 14 (JDK 14). In addition, a JDK Enhancement Proposal (JEP) for JDK 14, posted in openjdk.java.net, would upgrade Java’s mapped byte buffers to support non-volatile memory.
If JDK 14 follows the six-month release cadence set for Java, the upgrade would arrive as a production release in March 2020. As a non-LTS (long term support) release, JDK 14 would be supported for six months before making way for a successor release.
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 allows developers to conditionally extract components from objects more concisely and safely.
Until the formal proposal of switch expressions arrives, non-volatile mapped byte buffers remain the lone officially proposed feature targeting JDK 14. 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.
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.
This story, “JDK 14: The new features in Java 14 ” was originally published by InfoWorld.