What’s New in Java 22? Explore 12 Key Features and Their Benefits

Java 22 introduces twelve enhancements—including seven preview and one incubator features—spanning language syntax, APIs, performance, and tooling, with detailed explanations of each JEP’s purpose, value, and impact on developer productivity and code readability.

Programmer DD
Programmer DD
Programmer DD
What’s New in Java 22? Explore 12 Key Features and Their Benefits

Just last night, Java 22 was officially released, bringing twelve enhancements, including seven preview features and one incubator feature, covering improvements to the language, APIs, performance, and tools.

Below we explore the new features.

Unnamed Variables & Patterns - JEP 456

JEP 456 introduces unnamed variables and patterns, using the underscore character to improve readability when a variable declaration or nested pattern is not needed.

Value

Captures developer intent by enforcing unused bindings or lambda parameters, clarifying code and reducing errors.

Improves maintainability by identifying declared but unused variables, such as those in catch clauses.

Allows multiple patterns in a single case label when none declare pattern variables.

Enhances readability of record patterns by eliminating unnecessary nested type patterns.

Statements before super (…) [Preview] - JEP 447

This preview lets statements that do not reference the instance being created appear before an explicit constructor call.

Value

Gives developers more freedom to express constructor behavior, reducing the need for auxiliary static methods or intermediate constructors.

Preserves the existing guarantee that constructors run top‑down during class instantiation, ensuring subclass code does not interfere with superclass initialization.

Requires no changes to the JVM; the language feature relies only on current JVM verification and execution capabilities.

String Templates (2nd Preview) - JEP 459

The second preview of string templates simplifies writing strings that contain runtime‑computed values.

Value

Simplifies Java code by allowing easy expression of strings with embedded runtime values.

Improves readability of mixed text and expressions, whether the text fits on a single line or spans multiple lines.

Enhances security by validating and converting embedded expressions, protecting against unsafe user‑provided strings.

Allows Java libraries to define custom formatting syntax within templates.

Facilitates APIs that accept non‑Java languages such as SQL, XML, or JSON.

Enables creation of non‑string values computed from literal text and embedded expressions without an intermediate string representation.

Implicitly Declared Classes and Instance Main Methods (2nd Preview) - JEP 463

This preview lets students write their first Java program without needing to understand full‑language features for large programs.

Value

Accelerates Java learning by providing a smooth entry point for beginners.

Allows educators to introduce concepts incrementally.

Enables students to write concise basic programs that can evolve gracefully as skills grow.

Reduces boilerplate for simple scripts and command‑line utilities.

Uses the same compilation and runtime tools as any Java program, avoiding a separate beginner toolchain.

Foreign Function & Memory API - JEP 454

This API allows Java programs to interoperate with code and data outside the JVM, calling native libraries and accessing native memory safely.

Value

Productivity: replaces fragile native methods and JNI with a concise, readable pure‑Java API.

Performance: offers access comparable to JNI and sun.misc.Unsafe, potentially better.

Broad platform support: enables discovery and invocation of native libraries on any JVM platform.

Consistency: provides structured access to unlimited‑size data across native, persistent, and managed heap memory.

Robustness: prevents use‑after‑free errors even across threads.

Integrity: allows unsafe operations with native code while warning users by default.

Class‑File API (Preview) - JEP 457

Provides a standard API for parsing, generating, and transforming Java class files.

Value

Enables frameworks and tools to automatically support the latest class‑file features in new JDK releases, facilitating rapid adoption of new language and VM capabilities.

Stream Gatherers (Preview) - JEP 461

Enhances the Stream API to support custom intermediate operations, allowing pipelines to transform data in ways not easily expressed with built‑in operations.

Value

Improves developer productivity and code readability by making common custom stream operations more expressive and flexible, supporting potentially unbounded streams.

Structured Concurrency (2nd Preview) - JEP 462

Structured concurrency treats related tasks running on different threads as a single unit, simplifying error handling, cancellation, and improving observability.

Value

Promotes a programming style that eliminates common risks such as thread leaks and delayed cancellation, while enhancing the observability of concurrent code.

Scoped Values (2nd Preview) - JEP 464

Provides an efficient way to share immutable data within and between threads.

Value

Ease of use: offers a model for sharing data inside a thread and with child threads, simplifying reasoning about data flow.

Understandability: makes the lifecycle of shared data visible in the code’s syntactic structure.

Robustness: ensures only legitimate callers can retrieve shared data.

Performance: treats shared data as immutable, allowing extensive thread sharing and runtime optimizations.

Vector API (7th Incubator) - JEP 460

An API for expressing vector computations that reliably compiles to optimal vector instructions on supported CPU architectures, delivering performance superior to equivalent scalar code.

Value

Provides a clear, concise API for expressing a wide range of vector calculations, including loops and control flow.

Designed to be architecture‑agnostic, enabling implementation on any platform with vector instructions.

Delivers reliable runtime compilation and performance on x64 and AArch64 architectures.

Regional Pinning for G1 - JEP 423

Implements region pinning in G1 to reduce latency, allowing JNI‑critical regions to run without disabling garbage collection.

Value

When using JNI, Java threads no longer need to wait for G1 GC to finish, improving developer efficiency.

Launch Multi‑File Source‑Code Programs - JEP 458

Allows users to run programs composed of multiple Java source files without prior compilation.

Value

Facilitates a gradual transition from small to large programs, letting developers decide when to configure build tools.

Preview features are fully specified and implemented but temporary, enabling feedback before permanent inclusion.

Incubator APIs expose non‑final features to collect feedback and ultimately improve the Java platform.

Other Updates

Additional algorithms to keytool and jarsigner.

Improved GC throughput, especially for young generation collectors.

Better system module descriptor version reporting.

Enhanced native‑code “wait” handling options.

Unicode CLDR data updated to version 44.

Type‑annotation support for types loaded from bytecode.

ForkJoinPool and ForkJoinTask now handle non‑blocking tasks more effectively.

More flexibility configuring client‑server TLS connection properties.

Improved native memory tracking with peak‑usage reporting.

Java 22 was delivered on schedule as the 13th feature release in Oracle’s six‑month cadence; it will receive updates until September 2023, after which Oracle JDK 23 will succeed it. The current long‑term support version is Java 21. For more in‑depth analysis of Java’s new features, visit the “Java New Features” column.

Javabackend developmentProgramming LanguageJEPJDK 22
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.