BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Java 22 Delivers Foreign Memory & Memory API, Unnamed Variables & Patterns, and Return of JavaOne

Java 22 Delivers Foreign Memory & Memory API, Unnamed Variables & Patterns, and Return of JavaOne

Oracle has released version 22 of the Java programming language and virtual machine. As the first non-LTS release since JDK 21, the 12 JEPs in this final feature set are:

Two of these - Foreign Function & Memory API and Unnamed Variables & Patterns - have completed their respective rounds of previews and are now finalized.

As shown in the graph below, the feature cadence for JDK 22 is similar to that of the previous releases dating back four years to JDK 14 with the exception of JDK 18, JDK 19 and JDK 20.

We examine some of these JEPs, discuss the JDK 22 Launch Event, and update our predictions for features that may be included in JDK 23.

Foreign Function & Memory API

JEP 454, Foreign Function & Memory API, finalizes this feature after two rounds of incubation and three rounds of preview, namely: JEP 412, Foreign Function & Memory API (Incubator), delivered in JDK 17; JEP 419, Foreign Function & Memory API (Second Incubator), delivered in JDK 18; JEP 424, Foreign Function & Memory API (Preview), delivered in JDK 19; JEP 434, Foreign Function & Memory API (Second Preview), delivered in JDK 20; and JEP 442, Foreign Function & Memory API (Third Preview), delivered in JDK 21. Improvements since the last release include: a new Enable-Native-Access manifest attribute that allows code in executable JARs to call restricted methods without the use of the --enable-native-access flag; allow clients to programmatically build C function descriptors, avoiding platform-specific constants; improved support for variable-length arrays in native memory; and support for multiple charsets in native strings. More details on JEP 454 may be found in this InfoQ news story.

Unnamed Variables and Patterns

JEP 456, Unnamed Variables & Patterns, finalizes this feature after one previous round of preview, namely JEP 443, Unnamed Patterns and Variables (Preview), delivered in JDK 21. This feature will "enhance the language with unnamed patterns, which match a record component without stating the component's name or type, and unnamed pattern variables, which can be initialized but not used." These are denoted by the underscore character as in instanceof Point(_, int y) for unnamed patterns, instanceof ColoredPoint(Point(int x, int _), Color _) for unnamed pattern variables, and var _ = q.remove() for local variables.

Implicitly Declared Classes and Instance Main Methods (Second Preview)

JEP 463, Implicitly Declared Classes and Instance Main Methods (Second Preview), formerly known as Unnamed Classes and Instance Main Methods (Preview), Flexible Main Methods and Anonymous Main Classes (Preview) and Implicit Classes and Enhanced Main Methods (Preview), incorporates enhancements in response to feedback from the previous round of preview, namely JEP 445, Unnamed Classes and Instance Main Methods (Preview). This JEP proposes to "evolve the Java language so that students can write their first programs without needing to understand language features designed for large programs." This feature moves forward the September 2022 blog post, Paving the on-ramp, by Brian Goetz, Java language architect at Oracle. Gavin Bierman, consulting member of Technical Staff at Oracle, has published the first draft of the specification document for review by the Java community. Further details on JEP 445 may be found in this InfoQ news story.

JDK 22 Launch Event

The JDK 22 Launch Event, live-streamed on March 19, 2024 from 17:00-22:00 UTC, was hosted by Ana-Maria Mihalceanu, Billy Korando and Nicolai Parlog, Java developer advocates at Oracle, featuring the following topics: Deep Dive into Java 22's Features; Java Outreach in 2024; and Java Preview Features and Future Work. The agenda and special guests included:

  • A keynote address by Brian Goetz
  • Foreign Function & Memory API with Jorn Vernee and Per Ake Minborg
  • JavaFX updates with Kevin Rushforth
  • A Java community update with Sharat Chander and Venkat Subramaniam
  • A graceful on-ramp to Java programming with Ron Pressler
  • A behind-the-scenes look at the Java Playground, a GUI based on the JShell utility to write and execute Java code, with David Delabassee and Denys Makogon
  • A sneak peek at GraalVM updates with Alina Yurenko and Fabio Niephaus
  • Stream Gatherers with Viktor Klang
  • Project Loom headlines with Alan Bateman
  • Project Babylon with Paul Sandoz
  • The state of Project Leyden with John Rose

Chander announced that JavaOne will return in 2025 to celebrate Java's 30th birthday. The conference, scheduled for March 17-20, 2025, will be held at the Oracle Conference Center in Redwood Shores, California. Developers are encouraged to subscribe for updates.

JDK 23

Scheduled for a GA release in September 2024, only one JEP has been targeted for JDK 23 at this time. However, based on a number of JEP candidates and drafts, especially those that have been submitted, we can surmise which additional JEPs have the potential to be included in JDK 23.

JEP 455, Primitive Types in Patterns, instanceof, and switch (Preview), has been Targeted for JDK 23. This JEP, under the auspices of Project Amber, proposes to enhance pattern matching by allowing primitive type patterns in all pattern contexts, and extend instanceof and switch to work with all primitive types. Aggelos Biboudis, principal member of technical staff at Oracle, has recently published an updated draft specification for this feature.

JEP 468, Derived Record Creation (Preview), currently in Candidate status, proposes to enhance the Java language with derived creation for records. Since records are immutable objects, developers frequently create new records from old records to model new data. Derived creation streamlines code by deriving a new record from an existing record, specifying only the components that are different.

JEP 467, Markdown Documentation Comments, currently in Candidate status, proposes to enable JavaDoc documentation comments to be written in Markdown rather than a mix of HTML and JavaDoc @ tags. This will allow for documentation comments that are easier to write and easier to read in source form.

JEP 466, Class-File API (Second Preview), currently in Candidate status, proposes a second round of preview to obtain feedback from the previous round of preview: JEP 457, Class-File API (Preview), delivered in JDK 22. This feature provides an API for parsing, generating, and transforming Java class files. This will initially serve as an internal replacement for ASM, the Java bytecode manipulation and analysis framework, in the JDK with plans to have it opened as a public API. Goetz has characterized ASM as "an old codebase with plenty of legacy baggage" and provided background information on how this draft will evolve and ultimately replace ASM.

JEP 465, String Templates, currently in Candidate status, proposes to finalize this feature after two rounds of preview, namely: JEP 459, String Templates (Second Preview), delivered in JDK 22; and JEP 430, String Templates (Preview), delivered in JDK 21. This feature enhances the Java programming language with string templates, string literals containing embedded expressions, that are interpreted at runtime where the embedded expressions are evaluated and verified. Further details on JEP 430 may be found in this InfoQ news story.

Paul Sandoz, Java architect at Oracle, has submitted JEP Draft 8326878, Vector API (Incubator). After seven rounds of incubation that were integrated from JDK 16 through JDK 22, this JEP proposes to re-incubate the API in JDK 23 with no API changes and no substantial implementation changes relative to JDK 22. This feature will introduce an API to "express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations."

NOTE: This re-incubation was to allow for further progress and subsequent completion of Project Valhalla before the Vector API can move forward.

Bierman and Archie Cobbs, founder and CEO at PatientEXP, have introduced JEP Draft 8325803, Flexible Constructor Bodies (Second Preview), a JEP that proposes a second round of preview and a name change to obtain feedback from the previous round of preview, namely JEP 447, Statements before super(...) (Preview), delivered in JDK 22. This feature allows statements that do not reference an instance being created to appear before the this() or super() calls in a constructor; and preserve existing safety and initialization guarantees for constructors. Changes in this JEP include: a treatment of local classes; and a relaxation of the restriction that fields can not be accessed before an explicit constructor invocation to a requirement that fields can not be read before an explicit constructor invocation. Bierman has provided an initial specification of this JEP for the Java community to review and provide feedback.

Viktor Klang, software architect, Java Platform Group at Oracle, has introduced JEP Draft 8327844, Stream Gatherers (Second Preview), that proposes a second round of preview from the previous round, namely JEP 461, Stream Gatherers (Preview), delivered in JDK 22. This will allow additional time for feedback and more experience with this feature with no user-facing changes over JEP 461. This feature was designed to enhance the Stream API to support custom intermediate operations that will "allow stream pipelines to transform data in ways that are not easily achievable with the existing built-in intermediate operations." More details on this JEP may be found in the original design document and this InfoQ news story.

The formal release date for JDK 23 is expected to be September 2024 as proposed by Mark Reinhold, chief architect, Java Platform Group at Oracle. Developers can anticipate a feature freeze in early-June 2024. More details on additional JEP drafts and candidates may be found in this more detailed InfoQ news story.

JDK 22 may now be downloaded from Oracle with binaries from other vendors expected to become available in the coming days.

Editor's Note

This new story was updated to correct the examples in the Unnamed Variables and Patterns section.

About the Author

Rate this Article

Adoption
Style

BT