Java 22 on a green background
April 2, 2024

What's New With Java 22

Java Updates

In case you missed it, Oracle released Java 22 on March 19, 2024. Java 22 is a short-term JDK release that will receive premier support from Oracle for six months.  

Java 22 includes 12 JEPs, or JDK enhancement proposals. JEPs are the means by which Oracle introduces new features into the JDK, either on a preview or permanent basis. Read on to learn more about what’s included in Java 22—and how JRebel supports the latest JDK.  

 

Back to top

Permanent Feature JEPs in Java 22 

Java 22 includes four permanent feature JEPs. These features have been introduced in previous JDKs and after iterations and refinements are ready for permanent release.  

JEP 423: Region Pinning for G1 

The goals of JEP 423 are to prevent stalling of threads due to JNI critical regions, additional latency to start a garbage collection due to JNI critical regions, and regressions in GC pause times when no JNI critical regions are active. Region Pinning for G1 also seeks to minimize regressions in GC pause times when JNI critical regions are active. 

JEP 454: Foreign Function & Memory API 

Does this JEP sound familiar? That’s for good reason. The Foreign Function & Memory (FFM) API was originally proposed as a preview feature by JEP 424 (JDK 19) and subsequently refined by JEPs JEP 434 (JDK 20) and JEP 442 (JDK 21). Now, it’s being introduced as a permanent feature in the JDK.  

By efficiently invoking code outside the JVM and by safely accessing memory not managed by the JVM, the API enables Java programs to call native libraries and process native data without the brittleness and danger of JNI. 

JEP 456: Unnamed Variables & Patterns 

Unnamed variables and unnamed patterns were a preview feature in Java 21 in JDK 21 (JEP 443). This feature is now being finalized without further change to enhance the Java programming language with unnamed variables and unnamed patterns, which can be used when variable declarations or nested patterns are required but never used.  

JEP 458: Launch Multi-File Source-Code Programs 

The stated goal of JEP 458 is to make the transition from small programs to larger ones more gradual, enabling developers to choose whether and when to go to the trouble of configuring a build tool. It’s not intended to use the “shebang” mechanism or to ease the use of external library dependencies in source-code programs. 

Back to top

Preview Feature JEPs in Java 22 

Preview features are JDK enhancements that have a roadmap commitment from Oracle, but that still may change (either subtly or substantially) in their design, specification, or implementation prior to permanent release.  

Java 22 includes seven preview features, many of which are second previews. Read on to learn more about each JEP.  

📚 Looking for more information about Java LTS?Check out this blog.  

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

When one class extends another, the subclass inherits functionality from the superclass and can add functionality by declaring its own fields and methods. The initial values of fields declared in the subclass can depend upon the initial values of fields declared in the superclass, so it is critical to initialize fields of the superclass first, before fields of the subclass. 

This JEP gives developers greater freedom to express the behavior of constructors, preserves the existing guarantee that constructors run in top-down order during class instantiation, ensuring that code in a subclass constructor cannot interfere with superclass, and does not require changes to the JVM. 

JEP 457: Class-File API (Preview) 

The Class-File API creates a standard API for parsing, generating, and transforming Java class files. This JEP enables JDK components to migrate to the standard API, and eventually remove the JDK's internal copy of the third-party ASM library. 

JEP 459: String Templates (Second Preview) 

String templates were first introduced in Java 21 and are being introduced as a preview feature for the second time. Except for a technical change in the types of template expressions, there are no additional changes.  

String templates complement Java's existing string literals and text blocks by coupling literal text with embedded expressions and template processors to produce specialized results. 

Want to learn more about string templates? Watch this on-demand webinar to learn more about the hidden gems of Java 21.  

JEP 461: Stream Gatherers (Preview) 

The goal of stream gatherers is to make stream pipelines more flexible and expressive. In addition, they allow custom intermediate operations to manipulate streams of infinite size (as much as possible). This will allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations. 

JEP 462: Structured Concurrency (Second Preview) 

The goals of structured concurrency are to promote a style of concurrent programming that can eliminate common risks arising from cancellation and shutdown, such as thread leaks and cancellation delays. This JEP also aims to improve the observability of concurrent code. Structured concurrency treats groups of related tasks running in different threads as a single unit of work. 

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

This JEP was first introduced in Java 21 as Unnamed Classes and Instance main Methods (JEP 445). It is now being reintroduced after significant changes. This preview feature is aimed at making the Java language more accessible to students.  

JEP 464: Scoped Values (Second Preview) 

Scoped values were first introduced as an incubator feature in Java 20 and as a preview feature in Java 21. It is being reintroduced as a preview feature without further change. Scoped values enable managed sharing of immutable data both with child frames in the same thread, and with child threads. 

Back to top

Incubator Feature JEP in Java 22 

Incubator features are features that are not yet mature, but are made available for early adopters to experiment with. Java 22 includes one incubator JEP.  

JEP 460: Vector API (Seventh Incubator) 

The Vector API was first proposed in Java 16 (JEP 338) as an incubating API. Further rounds of incubation were proposed in Java 17, Java 18, Java 19, Java 20, and Java 21. This JEP proposes to re-incubate the API in JDK 22, with minor enhancements in the API from Java 21. 

The stated goals are to create a platform-agnostic, clear and concise API. It's not a goal to enhance the existing auto-vectorization algorithm in HotSpot. 

Back to top

JRebel Updates for Java 22 

The most important change being introduced with JRebel 2024.2.0 is support for Java 22. JRebel continues a long-storied history of supporting the latest versions of Java as soon as the release is made available. You can count on JRebel being able to handle and display the changes made throughout this document.  

Most of the Java 22 features are focused on changes made to APIs and Java syntax which does not impact how JRebel interacts with your application on the JVM level. You can rest assured knowing that JRebel will continue to support all your changes in your application even if you are using Java 22. 

Back to top

Final Thoughts 

Leveraging the latest JDK enhancements is one way to increase efficiency in your Java development practice. Another, complimentary method is JRebel. By eliminating redeploys, you can visualize code changes instantly while maintaining application state.  

See how much time you can save during your 14-day free trial of JRebel 

Try Free

Back to top