Java 22 

Java 22 is a non-LTS feature release following Java 21 LTS. It preceded Java 23 (September 2024). Java 22 reached end-of-life in September 2024 and receives no further updates. 

Java 22 Release Details 

Release DateMarch 19, 2024
LTSNo
OpenJDK End-of-LifeSeptember 17, 2024
Class File Version66.0
Unicode Version15.1.0
Notable ForForeign Function & Memory API finalized, unnamed variables and patterns, stream gatherers preview 

Java 22 is end-of-life. Organizations running it should upgrade to a current LTS release: Java 21 or Java 25

Java 22 Language Features 

Unnamed Variables and Patterns (JEP 456) 

Finalized feature. Allows underscore (_) for variables that are never used and for pattern components you want to ignore. Eliminates compiler warnings for unused variables and simplifies catch blocks and lambda parameters. 

// Unused variable in try-with-resources 

try (var _ = ScopedContext.acquire()) { 

    doWork(); 

// Ignore parts of a record pattern 

if (obj instanceof Point(int x, _)) { 

    System.out.println(x); 

// Unused catch variable 

catch (Exception _) { 

    logFailure(); 

Statements before super() (Preview, JEP 447) 

First preview. Allows statements before super() in constructors. Previously, any computation before the parent constructor call required a separate static method. Now you can validate and compute arguments inline. 

public PositiveBigInteger(long value) { 

    if (value <= 0) throw new IllegalArgumentException(); 

    super(value); 

String Templates (Second Preview, JEP 459) 

Second preview of string interpolation with template expressions. Embeds expressions directly in string literals with automatic escaping for SQL, JSON, and other formats. Removed from Java 23 for redesign. 

String query = STR.”SELECT * FROM users WHERE name = \{name}”; 

String json = STR.””” 

    {“user”: “\{name}”, “age”: \{age}} 

    “””; 

Implicitly Declared Classes and Instance Main Methods (Second Preview, JEP 463) 

Second preview (renamed from “Unnamed Classes”). Simplifies entry-point declaration for beginners and scripting. A class with a main method no longer requires public static, String[] args, or an explicit class declaration. 

// Before: full boilerplate 

public class HelloWorld { 

    public static void main(String[] args) { 

        System.out.println(“Hello”); 

    } 

// Java 22: minimal 

void main() { 

    println(“Hello”); 

Finalized in Java 23 (JEP 477). 

Java 22 API Changes 

Foreign Function and Memory API (JEP 454) 

Finalized. Replaces JNI with a safe, performant API for calling native functions and managing off-heap memory. No more ByteBuffer alignment issues, no sun.misc.Unsafe, no JNI header generation. The result of four preview rounds across Java 14-21. 

Linker linker = Linker.nativeLinker(); 

SymbolLookup stdlib = linker.defaultLookup(); 

MethodHandle strlen = linker.downcallHandle( 

    stdlib.find(“strlen”).orElseThrow(), 

    FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) 

); 

Stream Gatherers (Preview, JEP 461) 

First preview. Enables custom intermediate operations on streams. Addresses gaps in the Stream API where built-in operations are insufficient (windowing, folding, prefix scans). 

list.stream() 

    .gather(gatherers.fixedWindow(3)) 

    .toList(); 

Finalized in Java 24 (JEP 485). 

Class-File API (Preview, JEP 457) 

First preview. Standard API for parsing, generating, and transforming Java class files. Replaces the need for third-party bytecode libraries (ASM, Byte Buddy) in the JDK itself and in build tools. Finalized in Java 24 (JEP 466). 

Structured Concurrency (Second Preview, JEP 462) 

Second preview. Simplifies concurrent programming by treating multiple tasks as a single unit of work. Re-previewed in Java 23-25. 

Java 22 Tools 

Launch Multi-File Source-Code Programs (JEP 458) 

Run programs consisting of multiple Java source files without a build tool. java command compiles and runs referenced source files automatically. Useful for scripting and teaching. 

java Main.java 

Where Main.java references Utils.java and other source files in the same directory. 

Java 22 JVM Changes 

Region Pinning for G1 (JEP 423) 

Reduces latency in G1 garbage collector during JNI critical region operations. Previously, G1 had to pin entire regions (and could not move or collect them) when native code held a critical array reference. Now only the specific object is pinned, not the entire region. 

Java 22 Upgrade Path 

Java 22 has been end-of-life since September 2024. Recommended upgrade targets: 

  • Java 21 LTS: Previous LTS. Virtual threads, record patterns, pattern matching for switch (all final). Stable and well-tested. 
  • Java 25 LTS: Current LTS. Adds compact source files, AOT method profiling, compact object headers. 

Java 22 applications can upgrade to Java 21 LTS (previous LTS, well-established) or Java 25 LTS (current). Both receive long-term support. 

Azul’s Java 22 Support 

Azul Platform Core provides TCK-certified builds of current LTS releases with extended support. A single subscription covers all supported versions from Java 6 through Java 26. 

Platform Core wide 1x

Contact Us

Contact us to learn more about our migration services, support, modernization services, and more!