Business-Blog

JDK 24: The new features in Java 24

The first features targeted to Java 24 include stream gatherers, a vector API, a class file API, a G1 garbage collector improvement, and warnings on unsafe uses of the Java Native Interface.

Due March 18, 2025, JDK 24 has been designated a non-long-term support (LTS) release. Like just-released JDK 23, JDK 24 will receive only six months of Premier- level support from Oracle. Early access builds of JDK 24 can be found at jdk.java.net.

The latest and sixth feature proposed for JDK 24 involves removing the non- generational mode of the Z Garbage Collector (ZGC) to reduce the maintenance cost of supporting two different modes.

The fifth feature proposed for JDK 24 is stream gatherers, which would enhance the stream API to support custom intermediate operations. Stream gatherers allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations. This feature was proposed as a preview in JDK 22 and JDK 23. The API would be finalized in JDK 24. Goals include making stream pipelines more flexible and expressive and allowing custom intermediate operations to manipulate streams of infinite size.

Also proposed for JDK 24 is the vector API. In what would be its ninth incubation, the vector API is designed to express vector communications that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.

The first JDK 24-targeted feature, officially called “Prepare to Restrict the Use of JNI,” calls for issuing warnings about uses of JNI and adjusting the foreign function and memory (FFM) API, featured in JDK 22, to issue warnings in a consistent manner.

The second feature, late barrier expansion for the G1 garbage collector, is intended to simplify the implementation of G1’s barriers. The G1 garbage collector’s barriers record information about application memory accesses, by shifting their expansion from early in the C2 compilation pipeline to later.

A fourth feature is preserving the quality of C2-generated JIT (just-in-time)- compiled code, in terms of speed and size.

A third feature, the class-file API, previously previewed in JDK 22 and JDK 23, would be finalized in JDK 24, with minor changes. This API provides a standard API for parsing, generating, and transforming Java class files. It aims to provide an API for processing class files that tracks the class file format defined by the Java Virtual Machine specification. A second goal is to enable JDK components to migrate to the standard API, and eventually remove the JDK’s internal copy of the third-party ASM library. Changes since the second preview include a renaming of enum values, removal of some fields, the addition of methods and method overloads, methods renamed, and removal of interfaces and methods deemed unnecessary.