DEV Community

Cover image for Exploring the New Features of Java 23
Kailash Nirmal
Kailash Nirmal

Posted on

Exploring the New Features of Java 23

Dear Developers, Programming Enthusiasts, and Learners,

Java Development Kit (JDK) 23 has officially been released (2024/09/17 General Availability) marking another significant milestone in the evolution of the Java programming language. This latest update introduces a plethora of exciting features and enhancements aimed at improving developer experience, performance, and modularity.

In this article, I’ll share some of the major highlights of JDK 23, which I’ve gathered through my research.

While I have not yet had the opportunity to try my hands on Java 23, I believe it's important to stay updated with these advancements
.

Major Highlights of JDK 23 :

1. Module Import Declarations (Preview)
JDK 23 introduces the ability to succinctly import all packages exported by a module, simplifying the reuse of modular libraries. This feature allows developers to avoid the clutter of multiple import statements and makes it easier for beginners to use third-party libraries without navigating complex package hierarchies.

2. Markdown Documentation Comments
With this new feature, JavaDoc comments can now be written in Markdown, enhancing readability and ease of writing. This allows developers to combine Markdown syntax with HTML and JavaDoc tags, improving the documentation experience and extending the Compiler Tree API to facilitate tools that analyze Markdown content.

3. Generational Z Garbage Collector (ZGC)
The default mode for the Z Garbage Collector has been switched to generational mode, which enhances Java application performance by collecting young objects more frequently. The previous non-generational mode has been deprecated, paving the way for improved garbage collection strategies in future releases.

4. Vector API (Eighth Incubation)
The Vector API allows developers to express vector computations that compile reliably at runtime to optimal vector instructions on supported CPU architectures. It aims to provide a clear and concise API while ensuring performance on x64 and AArch64 architectures, aligning with Project Valhalla.

5. Stream Gatherers (Second Preview)
Stream Gatherers enhance the existing Stream API by allowing custom intermediate operations to be defined, making stream pipelines more flexible and expressive. This feature empowers developers to manipulate streams of infinite size in ways that were previously difficult.

6. Class-File API (Preview)
The new Class-File API provides an interface for processing class files that aligns with the Java Virtual Machine specification. This API will facilitate the migration of JDK components to a standard API, ultimately helping to remove the internal ASM library from JDK.

7. Support for Primitive Types in Patterns, Instanceof, and Switch
This feature enhances Java's pattern matching capabilities by allowing primitive type patterns in all contexts. It simplifies coding by making it easier to safely handle checks and casts for primitive types, thus improving the language's usability.

8. Flexible Constructor Bodies (Second Preview)
Flexible constructor bodies allow developers to initialize fields in a class before invoking any constructor, providing greater freedom in expressing constructor behavior while maintaining the guarantee of a top-down instantiation order.

9. Implicitly Declared Classes and Instance Methods (Second Preview)
This enhancement aims to simplify the learning curve for beginners by allowing the easy creation of single-class programs. It automatically imports essential methods for console I/O and public classes from the
java.base
module, facilitating a smoother learning experience.

10. Primitive Types in Patterns
This feature allows Java developers to use primitive types in pattern matching contexts, enhancing safety and flexibility in code.

11. String Templates (Dropped)
While string templates aimed to complement string literals and text blocks by embedding expressions, this feature was dropped from JDK 23 for further evaluation and potential redesign.

12. Future Plans and Support
JDK 23 is a non-LTS release, supported for only six months, in contrast to JDK 21, which is an LTS version. Oracle has also announced ongoing plans for Java in 2024, focusing on broader improvements and extending Java's capabilities to various programming models.

Conclusion :

JDK 23 is rich with features and enhancements that aim to refine the Java development experience. As I continue to explore this version, I look forward to testing these features firsthand and sharing my insights with you.

Note to Readers

I want to emphasize that the information presented in this article may not be exhaustive or perfectly accurate, as it has been collected from a variety of sources. I apologize for any inaccuracies or omissions. This article is based on my readings and understanding of JDK 23, and while I strive to provide accurate information, I encourage you to experiment and explore these features firsthand to gain deeper insights.

Thank you for your understanding, and I hope you find this information helpful as you navigate the latest updates in Java!

Thanks,
Kailash
JavaCharter

Top comments (4)

Collapse
 
luck_ge_971ec65caf1139a23 profile image
Luck Ge

please come on gmail geluck30@gmail.com

Collapse
 
kailashnirmal profile image
Kailash Nirmal

Hi Luck Ge,

Thank you for your comment on my article! I appreciate your engagement. However, I'm not quite sure what you meant by "please come on Gmail." Could you please clarify what you need help with or how I can assist you?

Collapse
 
luck_ge_971ec65caf1139a23 profile image
Luck Ge

please mesage on my gmail geluck30@gmail.com

Thread Thread
 
kailashnirmal profile image
Kailash Nirmal

Hi Luck Ge,

Thank you for clarifying! I will send you a message on your Gmail (geluck30@gmail.com) in a few hours. Looking forward to connecting!!