JDK 22 · JSR 397

Java 22

JDK 22 is Java SE 22, JSR 397, generally available on 19 March 2024. Unnamed variables and the foreign function and memory API become permanent. Stream gatherers, the class-file API, statements before super(...), and string templates are previews. Structured concurrency and scoped values are still previews.

How to read the status

Language

Statements before super(...) (Preview)

JEP 447 · Preview · Language

A constructor may run statements before super(...) or this(...). Those statements cannot use the object under construction. This is a preview.

Final in Java 25 as flexible constructor bodies (JEP 513).

OpenJDK JEP 447 (leaves JavaMastery)

Implicitly Declared Classes and Instance Main Methods (Second Preview)

JEP 463 · Preview · Language

The compact-program preview continues. A source file can still omit the usual class declaration.

First preview in Java 21 (JEP 445). Final in Java 25 (JEP 512).

OpenJDK JEP 463 (leaves JavaMastery)

String Templates (Second Preview)

JEP 459 · Preview · Language

String templates are previewed a second time. They are not finalized in this release.

First preview in Java 21 (JEP 430). They do not appear in the JDK 23, JDK 24, or JDK 25 feature lists.

OpenJDK JEP 459 (leaves JavaMastery)

APIs / Libraries

Foreign Function & Memory API

JEP 454 · Final · APIs / Libraries

Java programs can call native code and use off-heap memory through a standard API, without JNI for the common cases.

Incubated in Java 17 and Java 18. Preview in Java 19, Java 20, and Java 21.

OpenJDK JEP 454 (leaves JavaMastery)

Stream Gatherers (Preview)

JEP 461 · Preview · APIs / Libraries

A gatherer is a preview intermediate stream operation that can do more than the built-in operations.

Second preview in Java 23 (JEP 473). Final in Java 24 (JEP 485).

OpenJDK JEP 461 (leaves JavaMastery)

Related reading: Streams and Optional

Class-File API (Preview)

JEP 457 · Preview · APIs / Libraries

A preview API parses, generates, and transforms class files. It is not final.

Final in Java 24 (JEP 484).

OpenJDK JEP 457 (leaves JavaMastery)

JVM / Runtime

Tools / Platform

Launch Multi-File Source-Code Programs

JEP 458 · Final · Tools / Platform

The java launcher can run a program that is split across more than one source file, without a separate compile step.

OpenJDK JEP 458 (leaves JavaMastery)

Examples

  • versions7Java22Unnamed.javaJava 22 example · Requires Java 22An unnamed loop variable and an unnamed catch parameter. Final in Java 22. The preview was Java 21.

Related reading

Historical notes

String templates are still a preview. Nothing in Java 23, 24, or 25 turns them into a final feature.

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

All versions