}}
Java 21 was released on 19 September 2023.<ref name="JDK 21">{{Cite web |title=JDK 21 |url=https://openjdk.org/projects/jdk/21/ |access-date=June 12, 2023 |website=OpenJDK}}</ref> ThereThe are[[32-bit computing|32-bit]] version of Java for Windows on x86 was deprecated for removal with this release. The following JEPs were added, including eight JEPs that aregraduated notfrom inthe previewincubating orand incubatingpreview stages, compared to Java 20 which only had previewing and incubating JEPs. Java 21 introduces features first previewed in Java 17 (pattern matching for [[switch statement]]s) and Java 19 (record patterns). TheAll [[32-bitJEPs computing|32-bit]]added version ofwith Java for21 Windowsinclude onthe x86 has been deprecated for removal.following:
* {{Java JEP|430|String Templates (Preview)}}
*# {{Java JEP|431430|SequencedString CollectionsTemplates (Preview)}}
*# {{Java JEP|439431|GenerationalSequenced ZGCCollections}}
*# {{Java JEP|440439|RecordGenerational PatternsZGC}}
*# {{Java JEP|441440|PatternRecord Matching for switchPatterns}}
*# {{Java JEP|442441|ForeignPattern FunctionMatching &for Memory API (Third Preview)switch}}
*# {{Java JEP|443442|UnnamedForeign PatternsFunction and& VariablesMemory API (Third Preview)}}
*# {{Java JEP|444443|VirtualUnnamed ThreadsPatterns and Variables (Preview)}}
*# {{Java JEP|444|Virtual Threads}} # {{Java JEP|445|Unnamed Classes and Instance Main Methods (Preview)}}
*# {{Java JEP|446|Scoped Values (Preview)}}
*# {{Java JEP|448|Vector API (Sixth Incubator)}}
*# {{Java JEP|449|Deprecate the Windows 32-bit x86 Port for Removal}}
*# {{Java JEP|451|Prepare to Disallow the Dynamic Loading of Agents}}
*# {{Java JEP|452|Key Encapsulation Mechanism API}}
*# {{Java JEP|453|Structured Concurrency (Preview)}}
JEP 445, previewing unnamed classes, allows for a barebones Main class without boilerplate code:<syntaxhighlight lang="java" line="1">
}}
Java 22 was released on March 19, 2024.<ref name="JDK 22">{{Cite web |title=JDK 22 |url=https://openjdk.org/projects/jdk/22/ |access-date=April 10, 2024 |website=OpenJDK}}</ref><ref>{{Cite web |title=Oracle Releases Java 22 |url=https://www.oracle.com/news/announcement/oracle-releases-java-22-2024-03-19/ |access-date=2024-03-20 |website=oracle.com}}</ref> The following features, or JEPs, were added with this release:
*# {{Java JEP|423|Region Pinning for G1}}
*# {{Java JEP|447|Statements before super(...) (Preview)}}
*# {{Java JEP|454|Foreign Function & Memory API}}
*# {{Java JEP|456|Unnamed Variables & Patterns}}
*# {{Java JEP|457|Class-File API (Preview)}}
*# {{Java JEP|458|Launch Multi-File Source-Code Programs}}
*# {{Java JEP|459|String Templates (Second Preview)}}
*# {{Java JEP|460|Vector API (Seventh Incubator)}}
*# {{Java JEP|461|Stream Gatherers (Preview)}}
*# {{Java JEP|462|Structured Concurrency (Second Preview)}}
*# {{Java JEP|463|Implicitly Declared Classes and Instance Main Methods (Second Preview)}}
*# {{Java JEP|464|Scoped Values (Second Preview)}}
At least oneAn API hasrelated been removed fromto Java ; i.e. a very rarely-used API (for's threading ) wasimplementation, removed from Java 22<code>java. lang.Thread.countStackFrames< !-- "A corpus analysis of 30M classes in 131k artifacts from Maven Central found only 1 usages to this method. The 1 usage appears to be a class that just wraps all methods/code>, itwas doesn't actually make use of itremoved. : https://github.com/openjdk/jdk/pull/14257 --><ref name="removed_API_in Java_22">{{Cite web |title=Remove Thread.countStackFrames |url=https://bugs.openjdk.org/browse/JDK-8309196 |access-date=2024-04-16 |website=bugs.openjdk.org}}</ref><ref>{{Cite web |title=Java SE 22 ( JSR 397) |url=https://cr.openjdk.org/~iris/se/22/latestSpec/#APIs-removed |access-date=2024-04-16 |website=cr.openjdk.org}}</ref> ▼
<!--
In addition to language changes, significant changes have been made to the Java class library over the years, which has grown from a few hundred classes in JDK 1.0 to over three thousand in J2SE 5.0. Entire new APIs, such as [[Swing (Java)|Swing]] and [[Java 2D]], have evolved, and many of the original JDK 1.0 classes and methods have been [[deprecation|deprecated]] (thereof some "terminally deprecated"), e.g. related to finalization.<ref>{{Cite web |title=Deprecated List (Java SE 22) |url=https://cr.openjdk.org/~iris/se/22/latestSpec/api/deprecated-list.html |access-date=2024-04-16 |website=cr.openjdk.org}}</ref>
-->
▲At least one API has been removed from Java; i.e. a very rarely-used API (for threading) was removed from Java 22.<!-- "A corpus analysis of 30M classes in 131k artifacts from Maven Central found only 1 usages to this method. The 1 usage appears to be a class that just wraps all methods, it doesn't actually make use of it.: https://github.com/openjdk/jdk/pull/14257 --><ref name="removed_API_in Java_22">{{Cite web |title=Remove Thread.countStackFrames |url=https://bugs.openjdk.org/browse/JDK-8309196 |access-date=2024-04-16 |website=bugs.openjdk.org}}</ref><ref>{{Cite web |title=Java SE 22 ( JSR 397) |url=https://cr.openjdk.org/~iris/se/22/latestSpec/#APIs-removed |access-date=2024-04-16 |website=cr.openjdk.org}}</ref>
{{clear}}
|