Oracle announced the general availability of JDK 21 this Tuesday. It’s a new LTS with at least 8 years support!
Stable features include:
- 431: Sequenced Collections. new interfaces to represent collections with a defined encounter order.
- 439: Generational ZGC. extend the Z Garbage Collector (ZGC) to maintain separate generations for young and old objects.
- 440: Record Patterns. record patterns to deconstruct record values.
- 441: Pattern Matching for switch. pattern matching for switch expressions and statements.
- 444: Virtual Threads. lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications.
- 449: Deprecate the Windows 32-bit x86 Port for Removal
- 451: Prepare to Disallow the Dynamic Loading of Agents
- 452: Key Encapsulation Mechanism API. an encryption technique for securing symmetric keys using public key cryptography.
Preview features include:
- 430: String Templates. complement Java’s existing string literals and text blocks by coupling literal text with embedded expressions and template processors to produce specialized results.
- 442: Foreign Function & Memory API (Third Preview). an API by which Java programs can interoperate with code and data outside of the Java runtime.
- 443: Unnamed Patterns and Variables.
- 445: Unnamed Classes and Instance Main Methods
- 446: Scoped Values. values that may be safely and efficiently shared to methods without using method parameters.
- 453: Structured Concurrency. treats groups of related tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability.
Java 21 also introduced Vector API (Sixth Incubator), to express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations.
Get Java 21
Oracle provides official packages for Linux, macOS, and Windows. They are available to download at the link below:
Beginners may follow this tutorial to install it in your Linux.