JDK 17 · JSR 392 · Long-term support

Java 17

JDK 17 is Java SE 17, JSR 392, generally available on 14 September 2021. Vendors treat it as a long-term support release. Sealed classes become permanent. Pattern matching for switch is only a preview. The JDK strongly encapsulates its internals.

How to read the status

Language

Pattern Matching for switch (Preview)

JEP 406 · Preview · Language

A switch can test patterns, including types. In Java 17 this is a preview, not the final feature.

Further previews in Java 18, 19, and 20. Final in Java 21 (JEP 441).

OpenJDK JEP 406 (leaves JavaMastery)

Related reading: Control flow

APIs / Libraries

Enhanced Pseudo-Random Number Generators

JEP 356 · Final · APIs / Libraries

A common RandomGenerator API covers the JDK’s pseudorandom algorithms, including splittable generators.

OpenJDK JEP 356 (leaves JavaMastery)

Deprecate the Security Manager for Removal

JEP 411 · Final · APIs / Libraries

The Security Manager is deprecated and marked for removal. It is still present.

Java 24 permanently disables it (JEP 486).

OpenJDK JEP 411 (leaves JavaMastery)

Foreign Function & Memory API (Incubator)

JEP 412 · Incubator · APIs / Libraries

The foreign function and memory API incubates. It is not a preview or a standard API yet.

Preview in Java 19 through Java 21. Final in Java 22 (JEP 454).

OpenJDK JEP 412 (leaves JavaMastery)

Vector API (Second Incubator)

JEP 414 · Incubator · APIs / Libraries

The Vector API incubates again. It is still not a standard API.

First incubator in Java 16 (JEP 338). Still incubating in Java 25.

OpenJDK JEP 414 (leaves JavaMastery)

JVM / Runtime

Strongly Encapsulate JDK Internals

JEP 403 · Final · JVM / Runtime

The JDK no longer offers the Java 16 relaxation that opened internal APIs. Most internal elements stay inaccessible.

Java 16 encapsulated internals by default but still allowed a flag to relax it (JEP 396).

OpenJDK JEP 403 (leaves JavaMastery)

Related reading: JVM and memory

Restore Always-Strict Floating-Point Semantics

JEP 306 · Final · JVM / Runtime

Floating-point expressions are consistently strict. The old default that allowed extended precision is gone.

OpenJDK JEP 306 (leaves JavaMastery)

Also in this release: context-specific deserialization filters (JEP 415), removal of RMI Activation (JEP 407), and a macOS/AArch64 port (JEP 391).

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

Since Java 11, switch expressions became final in Java 14, text blocks in Java 15, and records and instanceof patterns in Java 16. Sealed classes become final here. Pattern matching for switch is still a preview, so the Java 17 example does not use it.

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

All versions