| title | Overview of New Features in Java 22 & 23 | |
|---|---|---|
| category | Java | |
| tag |
|
JDK 23, like JDK 22, is a non-LTS (Long-Term Support) version, with Oracle providing only six months of support. The next long-term support version is JDK 25, expected to be released in September next year.
The following chart shows the number of new features and update times for each version from JDK 8 to JDK 24:
Since JDK 22 and JDK 23 share many overlapping new features, this overview will primarily focus on JDK 23, while also highlighting some features unique to JDK 22.
JDK 23 includes a total of 12 new features:
- JEP 455: Primitive Types, instanceof, and switch in Patterns (Preview)
- JEP 456: Class File API (Second Preview)
- JEP 467: Markdown Documentation Comments
- JEP 469: Vector API (Eighth Incubator)
- JEP 473: Stream Collectors (Second Preview)
- JEP 471: Deprecate Memory Access Methods in sun.misc.Unsafe
- JEP 474: ZGC: Default Generational Mode
- JEP 476: Module Import Declarations (Preview)
- JEP 477: Unnamed Classes and Instance Main Methods (Third Preview)
- JEP 480: Structured Concurrency (Third Preview)
- JEP 481: Scoped Values (Third Preview)
- JEP 482: Flexible Constructor Bodies (Second Preview)
The new features in JDK 22 are as follows:
Among these, I will highlight the following three features for a detailed introduction:
- JEP 423: G1 Garbage Collector Region Pinning
- JEP 454: Foreign Function & Memory API
- JEP 456: Unnamed Patterns and Variables
- JEP 458: Launching Multi-File Source Code Programs
Before JEP 455, instanceof only supported reference types, and the case labels in switch expressions and statements could only use integer literals, enum constants, and string literals.
In the preview features of JEP 455, instanceof and switch fully support all primitive types, including byte, short, char, int, long, float, double, and boolean.
// Traditional approach
if (i >= -128 && i <= 127) {
byte b = (byte)i;
... b ...
}
// Improved using instanceof
if (i instanceof byte b) {
... b ...
}
long v = ...;
// Traditional approach
if (v == 1L) {
// ...
} else if (v == 2L) {
// ...
} else if (v == 10_000_000_000L) {
// ...
}
// Using long type case labels
switch (v) {
case 1L:
// ...
break;
case 2L:
// ...
break;
case 10_000_000_000L:
// ...
break;
default:
// ...
}The Class File API was first previewed in JDK 22, proposed by JEP 457.
The goal of the Class File API is to provide a standardized API for parsing, generating, and transforming Java class files, replacing the previous reliance on third-party libraries (like ASM

