JDK 14 · JSR 389

Java 14

JDK 14 is Java SE 14, JSR 389, generally available on 17 March 2020. Switch expressions become a permanent language feature. Records, pattern matching for instanceof, and text blocks are still previews. Helpful NullPointerExceptions are on by default.

How to read the status

Language

Pattern Matching for instanceof (Preview)

JEP 305 · Preview · Language

instanceof can bind the tested value to a pattern variable. This is a preview.

Second preview in Java 15 (JEP 375). Final in Java 16 (JEP 394).

OpenJDK JEP 305 (leaves JavaMastery)

Text Blocks (Second Preview)

JEP 368 · Preview · Language

Text blocks are previewed a second time. They are not yet a permanent literal.

First preview in Java 13 (JEP 355). Final in Java 15 (JEP 378).

OpenJDK JEP 368 (leaves JavaMastery)

Related reading: Strings

APIs / Libraries

Foreign-Memory Access API (Incubator)

JEP 370 · Incubator · APIs / Libraries

An incubator API reaches memory outside the Java heap. It is not a supported standard API.

This line of work becomes the Foreign Function and Memory API, which is final in Java 22 (JEP 454).

OpenJDK JEP 370 (leaves JavaMastery)

JVM / Runtime

Helpful NullPointerExceptions

JEP 358 · Final · JVM / Runtime

A NullPointerException can name which part of an expression was null. The feature is on by default.

OpenJDK JEP 358 (leaves JavaMastery)

Tools / Platform

Packaging Tool (Incubator)

JEP 343 · Incubator · Tools / Platform

jpackage is an incubator tool for packaging a Java application. It is not final.

Final in Java 16 (JEP 392).

OpenJDK JEP 343 (leaves JavaMastery)

Examples

  • versions5Java17Features.javaCumulative Java 12–17 example · Requires Java 17Final forms only: switch expressions from Java 14, text blocks from Java 15, records and instanceof patterns from Java 16, and sealed classes from Java 17. This is not a Java 12 preview program. Pattern matching for switch was still a preview in Java 17 and is not used.

Related reading

Historical notes

The cumulative example uses the final switch-expression syntax from this release together with later records, text blocks, and sealed classes. It is a Java 17 file.

Sources. General availability, JSR 389, and the JEP list: OpenJDK JDK 14. OpenJDK JDK 14 (leaves JavaMastery)

All versions