Java Development Kit 22, set to arrive in March 2024 as the next planned version of Java Standard Edition now has three features planned so far. A seventh incubator of a vector API and unnamed variables and patterns have just joined a foreign function and memory API as features due in JDK 22.
The vector API was in the “proposed to target” state as of October 30, while unnamed variables and patterns, and the foreign function and memory API were in the officially targeted stage. Early-access builds of JDK 22 are available at jdk.java.net for Linux, Windows, and Mac. Official descriptions of the three capabilities so far are as follows:
A vector API (seventh incubator) would express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, achieving performance superior to equivalent scalar computations. The API provides a way to write complex vector algorithms in Java, using the existing HotSpot auto-vectorization algorithm but with a user model that makes vectorization more predictable and robust.
This capability has been incubated in prior versions of Java dating back to JDK 16 in March 2021. Goals of the API include it being clear and concise, platform-agnostic, and offering reliable runtime compilation and performance on x64 AArch64 architectures as well as graceful degradation. This capability is intended to leverage Project Valhalla enhancements to the Java object model, enabling programs to work with value objects.
Unnamed variables and patterns can be used when variable declarations or nested patterns are required but never used. Goals of the plan include:
- Capturing developer intent that a given binding or lambda parameter is unused, and enforcing that property to clarify programs and reduce opportunities for error
- Improving code maintainability by identifying variables that must be declared but are not used
- Allowing multiple patterns to appear in a single case label, provided that none of them declares pattern variables
- Improving the readability of record patterns by eliding unnecessary nested type patterns
This proposal was previewed in JDK 21 and would be finalized without change in JDK 22.
The foreign function and memory API allows Java programs to interoperate with code and data outside of the Java runtime. By invoking foreign functions and safely accessing foreign memory, Java programs can call native libraries and process native data without the brittleness of JNI (Java Native Interface), the proposal states.
The foreign function and memory API previously was previewed in JDK 19, JDK 20, and JDK 21. It would be finalized in JDK 22. The latest revisions cover three areas: supporting arbitrary charsets for native strings, enabling clients to build C-language function descriptors programmatically, and introducing the Enable-Native-Access JAR-file manifest attribute. The latter allows executable JAR files to call restricted methods without having to use the —enable-native-access command-line option.
Due March 19, 2024, Java 22 is a Feature release that will receive six months of support from Oracle, unlike just-released JDK 21, which is a Long Term Support (LTS) release that will receive at least eight years of support. Companies besides Oracle could offer longer support for JDK 22 if they so choose. Standard Java updates occur every six months, and LTS releases arrive every two years.
Other capabilities likely to appear in JDK 22 include features also previously previewed, such as string templates and unnamed classes and instance main methods. Other capabilities that could make their first appearance in JDK 22 include previews of a class-file API for parsing, transforming, and generating Java files, and computed constants, which are immutable value holders that are initialized at most once. A Java stream gatherers proposal to improve stream operations also is a possibility.
Prior to general availability, JDK 22 is set to go through rampdown phases in December and January, followed by two release candidates in February 2024.
Copyright © 2023 IDG Communications, Inc.
This story originally Appeared on Infoworld