The Arrival of Java 21


Java 2025-07-30 Sharat Chander
Blog Image

JDK 21 is now available!

Oracle now offers JDK 21 for developers, end-users, and enterprises.

Oracle will offer long term support for Java 21 for at least eight years. This extended support period gives organizations flexibility to keep applications in production longer with minimal maintenance, and to eventually migrate on their own terms. Based on customer feedback and use in the Java ecosystem, Oracle has also announced that long term support for Java 11 has been extended through at least January 2032, providing at least eight more years of support and updates from Oracle.

Java 21, Together

As did with previous releases, Java 21 celebrates the contributions of many individuals and organizations in the OpenJDK Community — we all build Java, together!

JDK 21 Fix Ratio

The rate of change over time in the JDK releases has remained largely constant for years, but under the six-month cadence the pace at which production-ready features and improvements are delivered has sharply increased.

Instead of making tens of thousands of fixes and delivering close to one hundred JEPs (JDK Enhancement Proposals) every few years, as we did with yesteryear Major Releases, enhancements are delivered in leaner Feature Releases on a more manageable, predictable, six-month schedule. The changes range from significant new features to small enhancements to routine maintenance, bug fixes, and documentation improvements. Each change is represented in a single commit for a single issue in the JDK Bug System.


JEP 441: Pattern Matching for switch

  • JEP Goals:
    • Expands the expressiveness and applicability of switch expressions and statements by allowing patterns to appear in case labels.
  • Allows the historical null-hostility of switch to be relaxed when desired.
    • Increases the safety of switch statements by requiring that pattern switch statements cover all possible input values.
    • Ensures that all existing switch expressions and statements continue to compile with no changes and execute with identical semantics.
  • Related to:
    • [JDK 17] JEP 406: Pattern Matching for switch (Preview)
    • [JDK 18] JEP 420: Pattern Matching for switch (2nd Preview)
    • [JDK 19] JEP 427: Pattern Matching for switch (3rd Preview)
    • [JDK 20] JEP 433: Pattern Matching for switch (4th Preview)
  • Value:
    • Improves the productivity of the Java programming language by making it more semantic so that complex data-oriented queries can be expressed concisely and safely.

JEP 443: Unnamed Pattern and Variable (Preview)

  • JEP Goals:
    • Enhances the Java language with unnamed patterns, which match a record component without stating the component's name or type, and unnamed variables, which can be initialized but not used. Both are denoted by an underscore character, _.
  • Value:
    • Improves the readability of record patterns by eliding unnecessary nested patterns.
    • Improves the maintainability of all code by identifying variables that must be declared (e.g., in a catch clause) but will not be used.

JEP 445: Unnamed Classes and Instance Main Methods (Preview)

  • JEP Goals:
    • Offers a smooth on-ramp to Java so that educators can introduce programming concepts in a gradual manner.
    • Helps students to write basic programs in a concise manner and grow their code gracefully as their skills grow.
    • Reduces the ceremony of writing simple programs such as scripts and command-line utilities.
    • Does not introduce a separate beginner's dialect of Java.
    • Does not introduce a separate beginners' toolchain; student programs should be compiled and run with the same tools that compile and run any Java program.
  • Value:
    • Evolves the Java language by reducing the boilerplate and ceremony so that students can write their first programs without needing to understand language features designed for large programs.

Project Loom

JEP 444: Virtual Threads

  • JEP Goals:
    • Enables server applications written in the simple thread-per-request style to scale with near-optimal hardware utilization.
    • Enables existing code that uses the java.lang.Thread API to adopt virtual threads with minimal change.
    • Enables easy troubleshooting, debugging, and profiling of virtual threads with existing JDK tools.
  • Relates to:
    • [JDK 20] JEP 436: Virtual Threads (2nd Preview)
    • [JDK 19] JEP 425: Virtual Threads (Preview)
  • Value:
    • Accelerates application development productivity such as apps targeted for cloud environments by introducing Virtual threads, which are lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.

JEP 446: Scoped Values (Preview)

  • JEP Goals:
    • Enables the sharing of immutable data within and across threads.
  • Related to:
    • [JDK 20] JEP 429: Scoped Values (Incubator)
  • Value:
    • Ease of use — Provides a programming model to share data both within a thread and with child threads, so as to simplify reasoning about data flow.
    • Comprehensibility — Makes the lifetime of shared data visible from the syntactic structure of code.
    • Robustness — Ensures that data shared by a caller can be retrieved only by legitimate callees.
    • Performance — Treats shared data as immutable so as to allow sharing by a large number of threads, and to enable runtime optimizations.