Oracle has announced the release of Java 23, which contains a number of new language and library features, mostly in preview stages. 

According to Chad Arimura, VP of developer relations at Oracle, the fact that most of the JDK Enhancement Proposals (JEPs) in this release are previews of what’s to come rather than stable features is a sign that the feedback process is working. 

“The JEPs do oftentimes change and evolve a little bit through the process, and they end up being much better than they would have been had we just kind of thrown something over the wall based on a lot more limited feedback,” he said. 

The language features in Java 23 have come out of Project Amber, which is an OpenJDK initiative to “explore and incubate smaller, productivity-oriented Java language features.”

One of the Project Amber features in preview is primitive types in patterns, instanceof, and switch (JEP 455). This removes restrictions on primitive types when working with pattern matching, instanceof, and switch, enabling Java to be more expressive, resulting in improved productivity.

Another preview feature is module import declarations (JEP 476), which allows developers to import all the packages exported by a module without the importing code needing to be in a module. According to Oracle, this makes modular libraries more reusable and helps beginners more easily use third-party libraries without having to learn where in the package hierarchy they are located.

In its third preview, implicitly declared classes and instance main methods (JEP 477) is another feature designed for beginners and learners that enables students to write smaller programs without having to first learn language features that are designed for larger projects. 

According to Arimura, JEPs 476 and 477 are “all about continuing to reach the next generation of developers, continuing to chip away at the perception that Java is your parents language, and that it’s boilerplate heavy and ceremony heavy.

And finally, in its second preview, is flexible constructor bodies (JEP 482). This gives developers more freedom in expressing the behavior of constructors by allowing statements to appear before an explicit constructor invocation. It preserves the guarantee that during class instantiation, constructors run in top-down order. 

The next major category of updates are to the libraries. Class-File API (in second preview) is a standard API for parsing, generating, and transforming Java class files. In its eighth incubator stage, JEP 469, the Vector API is an API that expresses “vector computations that reliably compile at runtime to vector instructions on supported CPU architectures,” which improves performance.

This release also includes a second preview of stream gatherers (JEP 473), which enables the Stream API to support custom intermediate operations. 

Other library updates include JEPs 480 and 481, both in their third preview. 480 is structured concurrency, which enables developers to consolidate groups of related tasks that are running in different threads. 481 is scoped values, which enables “sharing of immutable data within and across threads.”  

In terms of performance and runtime, the major update in Java 23 is that the Z Garbage Collector’s (ZGC) default mode is now the generational mode. The non-generational mode is being deprecated and will be removed in a future release.

Another inclusion in Java 23 by Oracle is the addition of the Graal JIT compiler in Oracle JDK. This means that features developed in the GraalVM EE can now be accessed by Oracle JDK users.

According to Oracle, this addition offers developers and system administrators more opportunities for fine tuning and improving workload performance. 

“We wanted to make it so that people had easy access to it, and so you can easily go and try this out now if you’re using the Oracle JDK, and you don’t have to download anything else to get there,” said Arimura.

And finally, notably absent from this release is the JEP for String Templates, which has been removed and is actively being reworked based on community feedback. 

“It doesn’t mean that the goals aren’t relevant, but it does mean that there may be a new way that we go about achieving those goals,” Arimura said.