Java 21, 22, 23 Features

Java 21, 22, 23 Features

JDK 21 and 22 Highlights

JDK 21, a long-term support release, introduced several key improvements:

  • Preview of pattern matching for switch expressions
  • Enhanced pseudo-random number generator
  • Project Loom’s preview of virtual threads
  • Continued optimization of memory management in Project ZGC

JDK 22 built on these advancements with:

  • Improvements in record patterns
  • Introduction of code snippets in JavaDoc
  • Preview of structured concurrency

These releases set the stage for further enhancements in JDK 23.

New Features in JDK 23

JDK 23, a non-LTS update, introduces twelve new features across four main areas:

Core Java Library:
  • Class-File API (JEP 466)
  • Vector API (8th incubation, JEP 469)
  • Deprecation of memory-access methods (JEP 471)
  • Stream gatherers (JEP 473)
  • Structured concurrency (3rd preview, JEP 480)
  • Scoped values (3rd preview, JEP 481)
Java Language Specification:
  • Primitive Types in Patterns (JEP 455)
  • Module import declarations (JEP 476)
  • Implicitly declared classes (JEP 477)
  • Flexible constructor bodies (JEP 482)
HotSpot:
  • Z Garbage Collector using generational mode by default (JEP 474)
Java Tools:
  • Markdown Documentation Comments (JEP 467)

These features aim to improve performance, enhance code understanding, and provide more expressive power in programming.

A visual representation of JDK 23's new features across four main areas: Core Java Library, Java Language Specification, HotSpot, and Java Tools

Project Connections and Developments

JDK 23’s features demonstrate clear connections to major Java projects:

ProjectRelated Features
Project AmberFlexible Constructor Bodies (JEP 482), Implicitly Declared Classes (JEP 477)
Project LoomScoped Values (JEP 481), Structured Concurrency (JEP 480)
Project PanamaVector API (JEP 469)
Project ValhallaEnhanced pattern matching capabilities (JEP 455)

These projects contribute to Java’s ongoing development, balancing future ambitions with practical enhancements.

Update on Deprecated Features

JDK 23 deprecates memory access methods in sun.misc.Unsafe, encouraging developers to use modern, standardized APIs like VarHandle and the Foreign Function & Memory API. This change aims to improve safety and predictability in Java development.

“Library developers are encouraged to migrate from sun.misc.Unsafe to supported replacements, so applications can migrate smoothly to modern JDK releases.”

The deprecation prepares developers for the eventual removal of these methods, reflecting a broader intent to cultivate a Java ecosystem that’s both powerful and stable.

Implications for Future Java Releases

JDK 23’s changes provide insight into future releases:

  • Continued focus on safety and modernization
  • Likely continuation of quick change cycles in non-LTS releases
  • Further development of concurrent programming features
  • Careful introduction of changes that enhance functionality while offering smooth transitions for existing codebases

JDK 24, scheduled for a GA release in March 2025, is expected to build on these trends. Some potential inclusions for JDK 24 are:

  • JEP 472: Prepare to Restrict the Use of JNI
  • JEP 404: Value Classes and Objects (Preview)
  • Generational Shenandoah (Experimental)
  • Class-File API finalization
  • Support for HTTP/3 in the HttpClient

These potential features indicate Java’s commitment to maintaining its balance of innovation and stability.

JDK 23 advances Java’s capabilities, encouraging developers to adopt safer and more efficient coding practices. Each release aims to balance innovation with reliability, ensuring Java remains a dependable tool for developers worldwide. As Java continues to evolve, it maintains its position as a versatile and powerful programming language, adapting to the changing needs of the software development landscape.

  1. Reinhold M. JDK 23 Release Candidate Phase. Oracle Corporation. 2024.
  2. Oracle Corporation. Java Development Kit 23 Documentation. 2024.
  3. OpenJDK. JEP 471: Deprecate the Memory-Access Methods in sun.misc.Unsafe for Removal. 2024.
  4. Oracle Corporation. Java Management Service 9.0 Documentation. 2024.

Social Links- Dev Community Youtube  Instagram