Java 23 Preview: Upcoming Features Include Module Import Declarations, Stream Gatherers, Structured Concurrency, and Scoped Values—String Templates Not Included
The Java Development Kit (JDK) 23, set for release on September 17, has finalized its feature set, presenting a mix of enhancements and previews. Notably, the anticipated third preview of string templates, which appeared in JDK 21 and JDK 22, has been omitted from this release. Instead, JDK 23 will focus on refining several other features and introducing new capabilities.
Among the highlights of JDK 23 are the third previews of scoped values, structured concurrency, and implicitly declared classes and instance methods. These features aim to improve the expressiveness and efficiency of Java code. Scoped values will enhance the management of temporary data, while structured concurrency is designed to simplify the handling of multiple concurrent tasks. Implicitly declared classes and instance methods aim to reduce boilerplate code, further streamlining development.
Additionally, JDK 23 will offer the second previews of flexible constructor bodies, stream gatherers, and a class-file API. Flexible constructor bodies provide more control over object initialization, stream gatherers introduce new ways to collect data from streams, and the class-file API enables more sophisticated manipulation of class files at runtime. These updates promise to enhance Java’s capabilities for handling modern programming challenges.
The release will also feature module import declarations, which will streamline the module system, and Markdown documentation comments to improve readability and maintainability of code documentation. The vector API, now in its eighth incubation phase, continues to evolve, aiming to provide efficient access to hardware vector operations. Moreover, a preview of primitive types in patterns, instanceof, and switch will bring new syntactical flexibility to the language.
JDK 23 will deprecate the memory access methods in sun.misc.Unsafe
, reflecting ongoing efforts to modernize and secure the Java platform. The generational mode of the Z Garbage Collector (ZGC) will become the default, offering improved performance for garbage collection.
As a non-LTS (Long Term Support) release, JDK 23 will only receive six months of support from Oracle, in contrast to the multi-year support offered for LTS releases like JDK 21. Developers interested in exploring JDK 23 can access early builds from the official JDK website, providing an opportunity to test and prepare for the new features ahead of the official release