ceritasaham 

JDK 22 Changelog: All New Features

JDK 22 Changelog: All New Features

A complete list of features and JEPs in JDK 22 (March 2024), including the Foreign Function & Memory API, Unnamed Variables & Patterns, and multi-file source-code programs.

20 September 2026#java#jdk#changelog#jdk-22

JDK 22 Changelog

JDK 22 was released on 19 March 2024 as a non-LTS release. Its headline feature is the Foreign Function & Memory API reaching final form, together with Unnamed Variables & Patterns and the ability to run multi-file source-code programs directly.

JEP Summary

JEP NumberFeature
423Region Pinning for G1
447Statements before super(...) (Preview)
454Foreign Function & Memory API
456Unnamed Variables & Patterns
457Class-File API (Preview)
458Launch Multi-File Source-Code Programs
459String Templates (Second Preview)
460Vector API (Seventh Incubator)
461Stream Gatherers (Preview)
462Structured Concurrency (Second Preview)
463Implicitly Declared Classes and Instance Main Methods (Second Preview)
464Scoped Values (Second Preview)

Key Features

Foreign Function & Memory API Is Now Standard (JEP 454)

After several preview and incubator rounds, the FFI (Foreign Function & Memory) API is finalized. It lets Java call native functions and access memory outside the JVM directly through MethodHandle:

// Call a C function from Java
FunctionDescriptor GETPID = FunctionDescriptor.of(ValueLayout.JAVA_INT, MemorySegment.NULL);
Linker linker = Linker.nativeLinker();
try (var libc = linker.defaultLookup().find("getpid").get()) {
    MethodHandle getpid = linker.downcallHandle(libc, GETPID);
    System.out.println("PID: " + (int) getpid.invoke());
}

Unnamed Variables & Patterns (JEP 456)

Unused variables can be named _, keeping the code cleaner and the pattern matching more explicit:

try (var stream = URL.openStream()) {
    stream.readAllBytes();
} catch (IOException _) {
    System.err.println("Network error");
}

// In a record pattern
if (obj instanceof Point(var x, _)) {
    System.out.println("x = " + x);
}

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

The java launcher can now run a source program made of several .java files in the same directory, without compiling first with javac:

# All .java files in the folder are compiled and run on the fly
java --source 22 src/app.java

This convenience makes local experimentation much simpler while keeping single-file support intact.

Statements before super(...) (JEP 447) — Preview

You can run statements before the super(...) call in a constructor, reducing the need for extra static helpers:

class Shape {
    final double area;
    Shape(double area) { this.area = area; }
}

class Circle extends Shape {
    Circle(double radius) {
        // Statements before super(...) — Preview
        if (radius < 0) throw new IllegalArgumentException("negative");
        super(Math.PI * radius * radius);
    }
}

Region Pinning for G1 (JEP 423)

The G1 collector now supports region pinning, allowing memory regions to be held during native code execution (notably via JNI/FFI) and reducing the pauses caused by compaction:

java -XX:+UseG1GC -jar app.jar

Stream Gatherers (JEP 461) — Preview

New gatherers for Stream provide grouping/windowing operations, simplifying complex aggregations:

List<String> groups = Stream.of("a", "b", "c", "d")
    .gather(Gatherers.windowSliding(2))
    .map(w -> w.get(0) + w.get(1))
    .toList();

String Templates (JEP 459) — Second Preview

String Templates continue evolving toward safer, more composable string interpolation through custom processors:

String name = "Ada";
String msg = STR."Hello, \{name}!";

Other Changes

  • Scoped Values (464): Second preview.
  • Structured Concurrency (462): Second preview.
  • Implicitly Declared Classes and Instance Main Methods (463): Second preview.
  • Class-File API (457): First preview; a new API for manipulating .class files.
  • Vector API (460): Seventh incubator.
  • Removed the Thread.countStackFrames API (broken and rarely used).

Conclusion

JDK 22 is a non-LTS but strategic release: it completes the Foreign Function & Memory API from Project Panama, lays the groundwork for flexible constructor bodies, and improves the developer experience with multi-file execution. It is a solid release for trying out the latest language features ahead of the next LTS.

mode [MARKET REGULER]build #ba129dblast update: Sep 22, 2026, 07:43:27 PM UTC▚▚ DYOR! Disclaimer ON! ▚▚