JDK 16 · JSR 391

Java 16

JDK 16 is Java SE 16, JSR 391, generally available on 16 March 2021. Records and pattern matching for instanceof become permanent. Sealed classes are still a preview. jpackage leaves the incubator. Stream.toList() arrives in this release.

How to read the status

Language

APIs / Libraries

Stream.toList()

Final · APIs / Libraries

Stream gains toList(), which returns an unmodifiable list. The Java 9–11 example does not call it. It keeps Collectors.toList() so that file can stay a Java 11 program.

Related reading: Streams and Optional

Vector API (Incubator)

JEP 338 · Incubator · APIs / Libraries

An incubator API for vector computations. It is not a standard API.

It is still incubating in Java 25, as the tenth incubator (JEP 508).

OpenJDK JEP 338 (leaves JavaMastery)

JVM / Runtime

Strongly Encapsulate JDK Internals by Default

JEP 396 · Final · JVM / Runtime

JDK-internal APIs are strongly encapsulated by default. The choice can still be relaxed. Java 17 removes that relaxation for most internals.

OpenJDK JEP 396 (leaves JavaMastery)

Related reading: JVM and memory

Tools / Platform

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’s records and instanceof patterns match this release. Its sealed classes match the Java 17 final form, so the file is not a Java 16 program.

Sources. General availability and the JEP list: OpenJDK JDK 16. JSR 391: Oracle Java SE specifications. OpenJDK JDK 16 (leaves JavaMastery)

All versions