Java 24 was officially released on March 18, 2025! While this is not a Long-Term Support (LTS) version, it's an important step towards the next LTS release, Java 25, coming in September 2025.
With over 20 JEPs (JDK Enhancement Proposals), this release brings exciting new features and significant performance improvements. Let’s explore some of the key highlights!
🔥 What's New in Java 24?
Here are the JEPs included in Java 24:
404: Generational Shenandoah (Experimental)
450: Compact Object Headers (Experimental)
472: Prepare to Restrict the Use of JNI
475: Late Barrier Expansion for G1
478: Key Derivation Function API (Preview)
479: Remove the Windows 32-bit x86 Port
483: Ahead-of-Time Class Loading & Linking
484: Class-File API
485: Stream Gatherers
486: Permanently Disable the Security Manager
487: Scoped Values (Fourth Preview)
488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
489: Vector API (Ninth Incubator)
490: ZGC: Remove the Non-Generational Mode
491: Synchronize Virtual Threads without Pinning
492: Flexible Constructor Bodies (Third Preview)
493: Linking Run-Time Images without JMODs
494: Module Import Declarations (Second Preview)
495: Simple Source Files and Instance Main Methods (Fourth Preview)
496: Quantum-Resistant Module-Lattice-Based Key Encapsulation Mechanism
497: Quantum-Resistant Module-Lattice-Based Digital Signature Algorithm
498: Warn upon Use of Memory-Access Methods in sun.misc.Unsafe
499: Structured Concurrency (Fourth Preview)
501: Deprecate the 32-bit x86 Port for Removal
With so many new features, let’s dive into a couple of key updates that can significantly boost productivity for developers.
488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
Java 21 introduced pattern matching for switch
(JEP 441), and now, Java 24 extends this feature to primitive types.
Pattern matching simplifies complex conditional logic, making code cleaner and more readable. Let’s see an example:
public String getAgeRange(int age) {
return switch (age) {
case 0 -> throw new IllegalArgumentException("Wrong Age");
case int i when i <= 20 -> "KID";
case int i when i >= 21 && i<=50 -> "ADULT";
case int i when i >= 50 -> "OLDER";
default -> "N/A";
};
}
485: Stream Gatherers
One of the most exciting additions in Java 24 is Stream Gatherers. This new feature introduces a powerful intermediate operation for processing streams efficiently.
Stream Gather is a new intermediate stream operation that processes the elements of a stream by applying a user-defined entity called a gatherer. With the gather operation we can build efficient, parallel-ready streams that implement almost any intermediate operation.
The Stream Gather provides 4 methods: initializer, combiner, finisher and integrator. The only required method is the integrator, because of it, we can use the method Gatherer.of that receives a Gatherer.Integrator class.
Example:
public List<Integer> getValuesUntilOddNumber(List<Integer> values) {
return values
.stream()
.gather(Gatherer.of((Gatherer.Integrator<Void, Integer, Integer>) (_, value, downstream) -> {
if (value % 2 == 0) {
downstream.push(value);
return true;
}
return false;
}))
.toList();
}
In this example, we created a method that will return all the elements until the value is an odd number.
@Test
void testGetValuesUntilOddNumber() {
StreamGatherFinal streamGatherFinal = new StreamGatherFinal();
assertThat(streamGatherFinal.getValuesUntilOddNumber(List.of(1, 2, 3, 4, 5))).isEmpty();
assertThat(streamGatherFinal.getValuesUntilOddNumber(List.of(2, 4, 5, 6))).containsExactly(2, 4);
}
Performance enhancement
Java has made significant strides in performance improvements, focusing on reducing latency, lowering memory footprint, and increasing throughput.
✅ Garbage Collection Improvements
G1GC (JEP 475: Late Barrier Expansion for G1) – The default garbage collector has been further optimized for better performance and efficiency.
Shenandoah & ZGC – These low-pause-time garbage collectors continue to evolve, with pause times under 1 millisecond, making them excellent alternatives for applications requiring ultra-low latency.
Reduced Memory Footprint (JEP 450: Compact Object Headers - Experimental) – This release introduces experimental support for compact object headers, reducing the standard 12-byte object header to 8 bytes in 64-bit implementations, leading to a more efficient Java heap footprint.
✅ Faster Startup Times
Project Leyden & JEP 483 (Ahead-of-Time Class Loading & Linking) – This initiative aims to reduce startup time, and you can already use it with Spring Boot application.
If you’d like to learn more about Java’s startup optimizations, I’ve discussed them in detail here:
Conclusion
Java continues to evolve, and Java 24 brings powerful new features that improve developer productivity and application performance.
These are just a few highlights—if you want a deep dive into all the changes, I highly recommend reading Thiago Gonzaga's detailed article on Java 24:
🔗 Why You Should Consider Migrating to Java 24
💻 Access the code shared in this post: GitHub Repository
If you want to keep up with Java news, productivity tips, and career growth strategies, subscribe for free now! 🚀
References
https://openjdk.org/projects/jdk/24/
https://www.oracle.com/java/technologies/javase/24all-relnotes.html
Missing in your list is the new `Reader.of(CharSequence)` which provides better performance and efficiency over the old-schoold `StringReader`, as it prevents in-memory copies and is non-synchronized.
JavaDocs: https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/io/Reader.html#of(java.lang.CharSequence)
RFE: https://bugs.openjdk.org/browse/JDK-8341566