Scheduled for release on September 19, Java 23 is poised to introduce several compelling features. Among the highlights are previews of stream gatherers, a class-file API, and enhancements to primitive types in patterns, instanceof, and switch.
The upcoming JDK 23 will mark the eighth incubation of the vector API, alongside a second preview of stream gatherers. This API, previously featured in JDK versions from 16 to 22, aims to provide a seamless way to express vector computations that efficiently compile to optimal vector instructions on supported CPU architectures. The goals include delivering a concise and clear API, ensuring reliable runtime compilation and performance across architectures, and aligning with Project Valhalla to enhance the Java object model with value objects.
Stream gatherers, initially previewed in JDK 22, offer enhanced support for custom intermediate operations within the stream API. This feature empowers stream pipelines to manipulate data in novel ways not easily achievable with existing built-in intermediate operations. The primary objectives include bolstering flexibility and expressiveness in stream pipelines and enabling custom intermediate operations to handle streams of infinite size.
The class-file API, another anticipated addition to JDK 23, will provide a standardized interface for processing class files that adheres to the Java Virtual Machine specification. This API aims to facilitate the migration of JDK components to a standard API, potentially phasing out the JDK’s internal copy of the ASM library. Refinements to the class-file API include streamlining the CodeBuilder class and enhancing the ClassSignature class model for more accurate modeling of generic signatures.
Additionally, JDK 23 may feature primitive types in patterns, instanceof, and switch as another preview feature. This enhancement will extend pattern matching capabilities by allowing primitive type patterns in various contexts, including instanceof and switch statements. The objectives encompass improving pattern matching usability, aligning pattern types with instanceof, and enabling switch to handle values of any primitive type.
Several other features previewed in JDK 22, such as statements before super(), string templates, scoped values, implicitly declared classes and instance main methods, derived record creation, and the hot code heap proposal, are also under consideration for inclusion in JDK 23. Oracle has outlined ambitious plans for Java in 2024, emphasizing improvements across OpenJDK projects like Amber, Babylon, and Valhalla to enhance productivity, support foreign programming models, and address performance bottlenecks.