24.0.2

Latest release in branch Java SE 24
Released 9 months ago (15 Jul 2025)

Software Java/Java SE
Branch Java SE 24
Status
End of life
Java class file format major version 68.0
End of premier support Sep 2025
First official release version 24
First official release date 1 year ago (18 Mar 2025)
Release notes https://www.oracle.com/java/technologies/javase/24-0-2-relnotes.html
Documentation https://docs.oracle.com/javase/24
Download https://www.oracle.com/java/technologies/javase/jdk24-archive-downloads.html
Java/Java SE Java SE 24 Releases View full list

What Is New in Java 24

Java 24 is a standard-term support release delivering language enhancements, performance upgrades, and new APIs. It builds on the foundation laid by previous versions with incremental but impactful changes.

Category Key Updates
Language Features Statements before super(), String Templates (Second Preview)
Core Libraries New methods in Class, Stream, and Collection APIs
Security SHA-3 support in SunPKCS11 provider, TLS signature schemes configuration
Performance G1 GC region pinning improvements, ZGC parallel pre-touch
Tools jpackage updates for macOS, jshell enhancements
Deprecations & Removals Deprecated methods in java.lang.Thread, java.util.Properties

What are the key language changes in Java 24?

The headline language feature is JEP 447: Statements before super(). This allows constructors to execute code before an explicit constructor invocation, offering more flexibility in object initialization. It simplifies tasks like validating arguments or preparing helper data before the superclass constructor runs.

String Templates (JEP 459) enter their second preview. This feature enables string interpolation with template expressions, making complex string composition safer and more readable. In practice, this reduces the need for verbose concatenation or using StringBuilder for complex strings.

Example: Statements before super()

public class Subclass extends Superclass {
    private final int value;

    public Subclass(int input) {
        // Can now perform logic before calling super()
        if (input <= 0) {
            throw new IllegalArgumentException("Must be positive");
        }
        int processedValue = process(input);
        super(processedValue); // Explicit constructor call
        this.value = processedValue;
    }
    private int process(int x) { return x * 2; }
}

Which core library APIs got new methods?

Several core classes received useful new methods. The Class class now has getPermittedSubclasses() for inspecting sealed hierarchies. The Stream API gained mapMultiToInt, mapMultiToLong, and mapMultiToDouble methods for flat-mapping operations to primitive streams efficiently.

Collection utilities were enhanced with new static methods for creating unmodifiable collections from array arguments directly. These additions reduce boilerplate code for common tasks like creating fixed-size sets or lists from a set of elements.

Example: New Stream methods

List<String> list = Arrays.asList("1", "2", "three");
// Using new mapMultiToInt method
IntStream intStream = list.stream()
    .mapMultiToInt((s, consumer) -> {
        try {
            consumer.accept(Integer.parseInt(s));
        } catch (NumberFormatException ignored) {}
    });
intStream.forEach(System.out::println); // Outputs: 1, 2

What security improvements were made?

Java 24 enhances the SunPKCS11 provider with support for SHA-3 based signatures (SHA3-224, SHA3-256, SHA3-384, SHA3-512), aligning with modern cryptographic standards. TLS connections now offer more granular control over signature schemes through new system properties.

The KeyStore API improvements include better handling of secret keys, making it easier to manage sensitive data securely. These changes matter because they keep Java current with evolving security requirements and algorithms.

How does garbage collection performance improve?

The G1 garbage collector now better handles region pinning, which reduces latency spikes during operations that require memory pinning like JNI critical sections. This results in more consistent performance for applications using native libraries.

ZGC introduces parallel pre-touch functionality, speeding up heap initialization on large memory systems. For memory-intensive applications, this can significantly reduce startup time when using large heaps.

What tools and packaging changes should developers know?

The jpackage tool received updates for macOS, including better handling of file associations and runtime compression. jshell now supports additional feedback modes and has improved completion functionality for a smoother developer experience.

These tooling improvements make it easier to create native packages and experiment with code snippets. For desktop application developers, the jpackage enhancements are particularly valuable for distribution.

FAQ

Is Java 24 a long-term support (LTS) release?
No, Java 24 is a standard-term support release following Oracle's six-month release cadence. The next planned LTS is Java 25.

Can I use statements before super() in all constructors?
No, this feature only applies to constructors that have an explicit constructor invocation (a call to super() or this()). Constructors without such calls cannot use statements before super().

Do I need to modify my code for the deprecated Thread methods?
Not immediately. The deprecated methods in Thread and Properties are still functional but will produce warnings. You should plan to migrate from Thread.suspend() and Thread.resume() to the concurrency utilities in java.util.concurrent.

How stable are String Templates in this release?
String Templates remain in preview status (second preview). This means the feature is complete but not yet permanent, and you must enable preview features with --enable-preview to use them in production.

What's the benefit of the new Stream mapMulti methods?
The mapMulti methods provide a more efficient alternative to flatMap for certain operations, particularly when you need to map each element to zero or more elements in a primitive stream. They can reduce overhead from boxing and unboxing operations.

Releases In Branch Java SE 24

Version Release date
24.0.2 9 months ago
(15 Jul 2025)
24.0.1 1 year ago
(15 Apr 2025)
24 1 year ago
(18 Mar 2025)