In the upcoming Java Development Kit (JDK) 22, slated for release in March 2024 as the next iteration of Java Standard Edition, enthusiasts can anticipate a robust package of twelve features. As the codebase enters the rampdown phase, freezing the feature set, key additions include the second preview of scoped values and an inaugural look at stream gatherers.
JDK 22’s general availability is scheduled for March 19, following the rampdown one phase concluded on December 7. The second rampdown phase is set for January 18, with two release candidates in February. The meticulous bug examination process continues until the official release date.
Scoped Values: Among the pivotal additions is the introduction of scoped values, a feature facilitating secure and efficient data sharing within and across threads. Aiming to supersede thread-local variables, this enhancement is especially pertinent in environments with numerous thread variables. The design priorities include ease of use, comprehensibility, robustness, and optimal performance.
Stream Gatherers: The latest array of features also includes stream gatherers, poised to elevate the stream API by introducing support for custom intermediate operations. This empowers stream pipelines to transform data in ways not easily achievable with existing built-in intermediate operations.
These new elements join a diverse array of features, including a second preview of structured concurrency, advancements in string templates, unnamed variables and patterns, a foreign function and memory API, and more. Notably, KLAS Research has recognized Oracle Health’s significant growth in the U.S. Hospital EMR Market Share, underlining Oracle Health’s influence in the sector.
For a sneak peek into these innovations, early-access builds of JDK 22 are available at jdk.java.net for Linux, Windows, and Mac.
Structured Concurrency: Structured concurrency continues to simplify concurrent programming, treating groups of related tasks as a single unit of work across different threads. This approach enhances error handling, cancellation mechanisms, reliability, and observability. Previously previewed in JDK 21, structured concurrency has now been incubated to refine its functionality.
Enhancements to Java Launcher: The Java application launcher is set to receive an enhancement allowing it to run programs supplied as multiple files of Java source code. This feature aims to facilitate a gradual transition from small to larger programs, enabling developers to choose the optimal time for configuring a build tool.
Class-File API: The class-file API is introduced to provide a standardized approach for parsing, generating, and transforming Java class files. With the intention of enabling JDK components to migrate to this standard API, it also aims to eliminate the need for the JDK’s internal copy of the third-party ASM library.
Region Pinning for G1 Garbage Collector: The G1 garbage collector sees improvements with the introduction of region pinning, designed to reduce latency during Java Native Interface (JNI) critical regions. This enhancement ensures that garbage collection need not be disabled during JNI critical regions, contributing to improved overall system performance.
Implicitly Declared Classes and Instance Methods: Under preview in JDK 21, this feature, initially named unnamed classes and instance methods, undergoes significant changes in JDK 22’s second preview. The goal is to evolve the Java language, allowing students to write streamlined declarations for single-class programs and seamlessly expand as their skills progress.
Statements Before super(…): Focused on constructors, this preview allows statements that do not reference the instance being created to appear before an explicit constructor. This provides developers with greater flexibility in expressing constructor behavior, without interfering with superclass instantiation.
String Templates: String templates, introduced in JDK 21’s first preview, complement Java’s string literals and text blocks. The second preview aims to gain additional experience and feedback, with the goal of simplifying the writing of Java programs and enhancing readability in expressions that mix text and dynamic expressions.
Vector API (Seventh Incubator): The vector API, in its seventh incubator, seeks to express vector computations that compile optimally at runtime to vector instructions on supported CPU architectures. This capability aims to achieve superior performance in vector algorithms, leveraging Project Valhalla enhancements to the Java object model.
Unnamed Variables and Patterns: Introduced in JDK 21, this feature captures developer intent when variable declarations or nested patterns are required but remain unused. The goal is to enhance code maintainability by identifying variables that must be declared but are not used, improving the overall readability of code.
Foreign Function and Memory API: Previously previewed in JDK 19, JDK 20, and JDK 21, the foreign function and memory API allows Java programs to interoperate with code and data outside the Java runtime. With additional revisions in JDK 22, this API offers flexibility in supporting arbitrary charsets for native strings and enabling programmatic building of C-language function descriptors.
Java 22, as a Feature release, will receive six months of support from Oracle. In contrast, the recently released JDK 21 is a Long Term Support (LTS) release, guaranteeing at least eight years of support. The rhythm of standard Java updates every six months and LTS releases every two years continues to drive the evolution of Java programming.