Java Development Kit (JDK) 21 officially arrived September 19, 2023. Next up is JDK 22, or Java 22, due March 19, 2024. A range of capabilities from structured concurrency to computed constants and a class-file API could make it into this future release.
JDK 22 is set to be published as a short-term release by Oracle with six months of support, although other organisations could offer longer support if they choose. Although the OpenJDK webpage for JDK 22 doesnâ€™t lists any features yet, obvious candidates include features previewed in JDK 21, such as structured concurrency for concurrent programming. Another possibility is a feature that was initially slotted for JDK 21 but was taken out: the Shenandoah garbage collector, a low-pause time collector. Early-access builds of JDK 22 are available at jdk.java.net. Other candidates for possible inclusion in JDK 22 include:
- A class-file API preview provides a standard API for parsing, generating, and transforming Java class files.
- A preview of computed constants, which are immutable value holders that are initialised at most once.
- A preview of value object storage enhancements, which allow programmers to enable more aggressive inlining of value objects in field and array components via non-atomic and null-restricted storage.
- Integrity and strong encapsulation restrict APIs so they cannot break strong encapsulation without explicit user permission, while still accommodating use cases that must operate beyond encapsulation boundaries.
- A preview of statements before
super(). In constructors, statements would be allowed that do not access the instance being created to appear prior to invocations of
super(), allowing more natural placement of initialisation logic.
- Preparations to restrict the use of JNI (Java Native Interface), supporting integrity-by-default through warnings issued when native code is invoked through JNI. This prepares for a future release that restricts the use of JNI to load native libraries and call native code. There is no plan to remove JNI from the platform.
- String templates, previewed in JDK 21, would complement string literals and text blocks by coupling literal text with embedded expressions and template processors. This capability would simplify the writing of Java programs.
- Foreign function and memory API was previewed for the third time in JDK 21. This feature lets Java programs interoperate with code and data outside the Java runtime.
- Unnamed patterns and variables, previewed in JDK 21, improve the readability of record patterns and the maintainability of all code.
- Unnamed classes and instance main methods, another feature previewed in JDK 21, evolve Java so students can write their first programs without having to understand language features designed for large programs.
- Vector API has been in an incubator phase for six straight releases of Java and would express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures. This would result in performance performance superior to equivalent scalar computations.
- Scoped values, previewed in JDK 21 and incubated in JDK 20, offer a programming model to share data both within a thread and child threads to simplify reasoning about data flow. Other goals cover comprehensibility of shared data, robustness, and performance.
Prior to the general release, JDK 22 is set for rampdown phases beginning December 7, 2023, and January 18, 2024; release candidates are due February 8 and February 22, 2024. JDK 21 was published on September 19, 2023, with Oracle designating it to be a long-term support release with at least eight years of support.