JDK 21, the upcoming long-term support (LTS) release of Oracle's Java Development Kit, is scheduled for release on September 19, 2023. It has recently entered the release candidate (RC) stage. Notably, JDK 21 will offer 15 features, as one of the initially proposed 16th features, the experimental Shenandoah garbage collector, was dropped in June.
These 15 features cover a wide spectrum of enhancements. Structured concurrency, for instance, simplifies concurrent programming by introducing an API for structured concurrency, improving error handling, and streamlining cancellation. Scoped values enable the sharing of immutable data across threads, offering an alternative to thread-local variables.
Another significant feature involves disallowing the dynamic loading of agents into a running JVM. This change aims to enhance security and integrity by requiring the application owner's approval for dynamic agent loading, aligning it with other "superpower" capabilities.
Furthermore, JDK 21 introduces an API for key encapsulation mechanisms, bolstering encryption techniques. It enables applications to utilize KEM algorithms for enhanced security, including those for Post-Quantum Cryptography standardization.
Additionally, JDK 21 marks the deprecation of the Windows 32-bit x86 port, setting the stage for its removal in future releases, considering Windows 10's end of life in October 2025.
In terms of language enhancements, JDK 21 offers preview features like unnamed classes and patterns, record patterns, and pattern matching for switch, enhancing the expressiveness and readability of Java code.
Moreover, Generational ZGC is designed to improve application performance by maintaining separate generations for young and old objects, reducing allocation stalls and garbage collection overhead.
Virtual threads, previewed in earlier versions, are now further refined. They aim to simplify concurrent application development, enabling server applications to scale efficiently and ensuring compatibility with existing code.
The release also brings in sequenced collections and string templates as preview features, streamlining operations on collections with defined encounter orders and simplifying the creation of strings with embedded expressions and processors.
As a long-term support release, JDK 21 will receive five years of premier support and extended support until September 2031, offering stability and support for critical applications. This release follows JDK 17, the previous LTS version, and is part of Oracle's commitment to a regular release cadence with LTS releases arriving every two years. Additionally, Oracle emphasizes changes in network interface naming on Windows and improvements in JDK Flight Recorder for streamlined flight recording analysis from the command line.