Feature Summary: Java SE 21

FeatureDescriptionJSR/JEPReleased in
UTF-8 by DefaultSets UTF-8 as the default charset for the Java API, ensuring consistent behaviour regardless of environment.JEP 400Java SE 18
Simple Web ServerA CLI tool for running a basic web server for prototyping and learning environments.JEP 408Java SE 18
Sequenced CollectionsIntroduces collections that maintain elements in a specific, predictable order, enhancing data handling.JEP 431Java SE 21
Generational ZGCImproves Z Garbage Collector for better performance in heap management by implementing generational collection techniques.JEP 439Java SE 21
Record PatternsExtends pattern matching to records, allowing for concise and safe deconstruction of records. Introduced in JEP 405 (Java SE 19).JEP 440Java SE 21
Pattern Matching for switchExtends pattern matching capabilities to switch expressions, simplifying complex chain of conditions. Introduced in JEP 406 (Java SE 17).JEP 441Java SE 21
Virtual ThreadsIntroduces lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications. Introduced in JEP 425 (Java SE 19).JEP 444Java SE 21
Key Encapsulation Mechanism APIProvides a new API to support modern cryptographic algorithms for encapsulating keys, enhancing security.JEP 452Java SE 21

Tools

Java SE 21 introduced several tools and utilities aimed at enhancing developer productivity and simplifying the development process.

  • Simple Web Server: A CLI tool for running a basic web server for prototyping and learning environments (JEP 408).

Java Syntax

This category includes fundamental changes and updates to the Java programming language, enhancing readability and reducing boilerplate code.

  • Pattern Matching for switch: Extends pattern matching capabilities to switch expressions, simplifying complex chains of conditions (JEP 441).
  • Record Patterns: Extends pattern matching to records, allowing for concise and safe deconstruction of records (JEP 440).
  • UTF-8 by Default: Sets UTF-8 as the default charset for the Java API, ensuring consistent behaviour regardless of the environment (JEP 400).

Libraries

Enhancements and additions to the Java standard API, providing new capabilities and simplifying common tasks.

  • Sequenced Collections: Introduces collections that maintain elements in a specific, predictable order, enhancing data handling (JEP 431).
  • Virtual Threads: Introduces lightweight threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications (JEP 444).
  • Key Encapsulation Mechanism API: Provides a new API to support modern cryptographic algorithms for encapsulating keys, enhancing security (JEP 452).

Performance & Security

Updates and improvements to the JVM and garbage collection, focusing on performance, security, and robustness.

  • Generational ZGC: Improves the Z Garbage Collector for better performance in heap management by implementing generational collection techniques (JEP 439).