The Arrival of Java 23!

Follow Java and OpenJDK on X.

JDK 23 is Now Available!

Oracle is proud to announce the general availability of JDK 23 for developers, enterprises, and end-users.

New with Java 23

JDK 23 delivers twelve enhancements that are significant enough to warrant their own JDK Enhancement Proposals - JEPs, including eight preview features and one incubator feature. They cover improvements to the Java Language, APIs, performance, and the tools included in the JDK. In addition to the work on the Java platform, with Oracle JDK 23 the Oracle GraalVM JIT compiler (Graal JIT) is now included among the JITs available as part of the Oracle JDK. For more information, see this separate blog post.

Language Improvements

Primitive Types in Patterns, instanceof, and switch (Preview) – JEP 455

This change will lift several restrictions that exist when using primitive types in pattern matching. Code that handles primitive types and object types can be simplified when no special allowances are needed and both types can be handled in the same manner. Allowing instanceof to accept primitives further reduces code for common cases as it can now handle conditional castings – where the value has to be checked to ensure it is valid for the target type – automatically.

Module Import Declarations (Preview) – JEP 476

Allows developers to import all the packages exported by a module with a single statement. This simplifies the reuse of modular libraries without requiring the importing code to be in a module itself. With this functionality beginners are able to use third-party libraries and fundamental Java classes without having to learn where they are in a package hierarchy.

Implicitly Declared Classes and Instance Main Methods (Third Preview) – JEP 477

This will allow beginners to write their first Java programs without having to first understand features meant for larger, more complex, programs. Simple programs can use streamlined declarations and, when required, seamlessly expand to use more advanced features as needed. Experienced developers too can enjoy writing small programs succinctly.

Flexible Constructor Bodies (Second Preview) – JEP 482

By allowing some statements in constructors to appear before an explicit constructor invocation, i.e., super(..) or this(..) developers gain the freedom to better express the behavior of constructors. The more natural placement of logic that this feature affords removes the need for factoring some of the checking and initialization logic into auxiliary static methods and auxiliary intermediate constructors. For example, if a constructor can validate the arguments it receives before invoking the super class constructor, it would fail quickly and avoid an unnecessary instantiation of the super class, when the arguments are invalid.

Libraries

Class-File API (Second Preview) – JEP 466

This JEP proposes an API for parsing, generating, and transforming Java class files that tracks the format defined by the Java Virtual Machine Specification. Having this API delivered as part of each Feature release will ease the tension introduced when Java adopted a six-month between releases cycle and forced frameworks that manipulate class files – which are updated with each release – into rapid adoption of new versions. When this feature is finalized, it should free the JDK itself from its reliance on the third-party ASM library.

Vector API (Eighth Incubator) - JEP 469

Allows Java developers 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. There are no differences from the 7th incubation of this feature in JDK 22. This API is expected to continue coming back as incubating – with only minor changes at best – until necessary features from Project Valhalla become available.

Stream Gatherers (Second Preview) – JEP 473

Enhances the Stream API to support custom intermediate operations. This will allow stream pipelines to transform data in ways not easily achievable with the existing built-in intermediate operations. Stream gatherers provide as much flexibility to intermediate operations as collectors allow for terminal operations. The second preview for this enhancement seeks for more community feedback while providing five built-in gatherers and an interface for defining your own customized gatherers.

Structured Concurrency (Third Preview) – JEP 480

Structured concurrency allows developers to treat groups of related tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability. This API promotes a style of concurrent programming which can eliminate common risks arising from cancellation and shutdown, such as thread leaks and cancellation delays.

Scoped Values (Third Preview) – JEP 481

This JEP will allow a method to share immutable data both, with its callees within a thread, and with child threads. Scoped values are easier to reason about than thread-local variables. They also have lower space and time costs, especially when used together with virtual threads (JEP 444) and structured concurrency (JEP 480).

Performance

ZGC: Generational Mode by Default – JEP 474

Switches the default mode of the Z Garbage Collector (ZGC) to the generational mode. Feedback from the use of generation ZGC, introduced in JDK 21, as well as in-house testing, has confirmed that it performs significantly better than non-gen ZGC in most use cases. This JEP also deprecates the non-generational ZGC mode, with the intent to remove it in a future JDK release.

Tooling

Markdown Document Comments – JEP 467

Enables using Markdown rather than solely a mixture of HTML and Javadoc @-tags for writing Javadoc documentation comments. The new format makes documentation in source form easier to read and understand.

Stewardship

Deprecate the Memory-Access Methods in sun.misc.unsafe for Removal – JEP 471

When access to most internal APIs was curtailed in JDK 9 (JEP 260) and further restricted with JDK 16 (JEP 396), and JDK 17 (JEP 403) a handful of internal unsupported API remained available as they were widely used for tasks for which no supported APIs was available. Our stated goal was to eventually provide supported APIs for those tasks and then limit access to those unsupported internal APIs. With the introduction of the Foreign Function and Memory API (JEP 454) in JDK 22 a supported API was provided for efficiently accessing off-heap (foreign) memory. We therefore are announcing the future removal of the methods in sun.misc.unsafe used for foreign memory access.

A Reminder on Preview and Incubator Features

Preview features are fully specified and fully implemented Language or VM Features of the Java SE Platform; and yet impermanent. They are made available in JDK Feature Releases to allow for developer feedback based on real-world uses, before becoming permanent in a future release. This also affords tool vendors the opportunity to work towards supporting features before they are finalized into the Java SE Standard.

APIs in Incubator modules put non-final APIs and non-final tools in the hands of developers and users so that we can gather feedback that will ultimately improve the quality of the Java platform.

Other Changes

Besides the changes described in the JEPs, there are many smaller changes listed in the release notes which will be of interest to many application developers and system administrators. These include deprecation of obsolete APIs and removal of previously deprecated ones.

Some of the key updates from the Java 23 release notes:

Console Methods With Explicit Locale (JDK-8330276)

The following methods have been added to java.io.Console class that take a java.util.Locale argument:

  • public Console format(Locale locale, String format, Object ... args)
  • public Console printf(Locale locale, String format, Object ... args)
  • public String readLine(Locale locale, String format, Object ... args)
  • public char[] readPassword(Locale locale, String format, Object ... args)

Users can now output the string or display the prompt text formatted with the specified Locale, which may be independent of the default locale. For example, a snippet System.console().printf(Locale.FRANCE, "%1$tY-%1$tB-%1$te %1$tA", new Date()) will display: 2024-mai-16 jeudi.

Add jdk.SerializationMisdeclaration JFR Event (JDK-8275338)

The new jdk.SerializationMisdeclaration JFR event is triggered at runtime when some aspect of serialization related fields and methods are improperly declared. By enabling jdk.SerializationMisdeclaration, JFR will trigger an event for each incorrectly declared aspect of a serializable class when it is loaded in the JVM.

For example, if the writeObject() method on a Serializable class has the correct signature but is unintentionally declared public, it is not selected by the serialization machinery. This might come as a surprise to the developer of the class. To help diagnose such problems, jdk.SerializationMisdeclaration events should be enabled.

The standard default.jfc profile does not enable these events, while the standard profile.jfc profile does.

Support for Duration Until Another Instant (JDK-8331202)

A new method has been added to the java.time.Instant class to obtain the Duration until the specified Instant. The new method: Instant.until(Instant) produces the same duration as Duration.between(Temporal, Temporal) but is easier for users to discover. This new method is more convenient than the method Instant.until(Temporal, TemporalUnit) in that the new method directly returns a Duration without a unit conversion.

Thread and Timestamp Options for java.security.debug System Property (JDK-8051959)

The java.security.debug system property now accepts arguments which add thread ID, thread name, caller information, and timestamp information to debug statements for all components or a specific component.

  • +timestamp can be appended to debug options to print a timestamp for that debug option.
  • +thread can be appended to debug options to print thread and caller information for that debug option.

Examples:

  • -Djava.security.debug=all+timestamp+thread adds timestamp and thread information to every debug statement generated.
  • -Djava.security.debug=properties+timestamp adds timestamp information to every debug statement generated for the properties component.

You can also specify -Djava.security.debug=help which will display a complete list of supported components and arguments.

Enable Case-Sensitive Check in ccache and keytab Kerberos Entry Lookup (JDK-8331975)

When looking up a keytab or credentials cache (ccache) entry for a Kerberos principal, the principal name is compared with the entry name in a case-insensitive manner. However, many Kerberos implementations treat principal names as case-sensitive. As a result, if two principals have names that differ only by case, there is a risk of selecting the incorrect keytab or ccache entry.

A new security property named jdk.security.krb5.name.case.sensitive is introduced to control name comparison. If this property is set to true, the comparison of principal names during keytab and ccache entry lookup will be case-sensitive. The default value is false to ensure backward compatibility.

In addition, if a system property with the same name is specified, it will override the security property value defined in the java.security file.

New javac -Xlint Suboption to Report “Dangling Doc Comments” (JDK-8303689)

A new suboption is provided for the javac -Xlint option, to detect issues related to the placement of documentation comments in source code.

The name for the new suboption is dangling-doc-comments. The suboption can be specified explicitly (for example, -Xlint:dangling-doc-comments) or implicitly, as one of all the suboptions (for example, -Xlint or -Xlint:all). When the suboption is enabled, javac will report any unexpected or misplaced documentation comments in the vicinity of a declaration, such as in the following situations:

  • a documentation comment for a top-level class before any package or import declaration;
  • a documentation comment for a declaration that appears after the first token of that declaration, such as after any annotations or other modifiers for the declaration; or
  • any additional documentation comments before a declaration, which javac would otherwise ignore.

As with any suboption for -Xlint, warnings can be suppressed locally, using an @SuppressWarnings annotation on an enclosing declaration, specifying the names of the suboptions for the warnings to be suppressed.

Improve Structural Navigation in API Documentation (JDK-8320458)

API documentation generated by the standard doclet now comes with enhanced navigation features, including a sidebar containing a table of contents for the current page, and breadcrumb navigation for the current API element in the page header.

In the documentation for classes and interfaces, entries in the table of contents can be filtered using a text input field at the top of the sidebar. A button at the bottom of the sidebar allows the table of contents to be collapsed or expanded for the current session.

Template for Creating Strict JAXP Configuration File (JDK-8330542)

Future JDK releases will continue to move towards making XML processing more restrictive by default. In order to help developers prepare for these changes, this release includes a JAXP Configuration File template, $JAVA_HOME/conf/jaxp-strict.properties.template, specifying more restrictive XML processing settings.

Finally, like all feature releases, JDK 23 includes hundreds of performance, stability, and security updates including adapting to underlying OS and firmware updates and standards. Users and application developers usually benefit from these changes without noticing them, but information on each of them can be found in the OpenJDK issue tracker.

And the constant feature, included in all JDK releases: Predictability

JDK 23 is the 14th Feature Release delivered on time through the six-month release cadence. This level of predictability allows developers to easily manage their adoption of innovation thanks to a steady stream of improvements.

Chart showing number of features per release since Java 8

Java’s ability to boost performance, stability, and security continues to make it the world’s most popular programming language.

Oracle will not offer long-term support for JDK 23; we will provide updates until March 2025 when it will be superseded by Oracle JDK 24.

Java 23, Together

As with previous releases, Java 23 is the result of the contributions of many individuals and organizations in the OpenJDK Community — we all build Java, together!

JDK 23 Fix Ratio

The rate of change over time in the JDK releases has remained largely constant for years, but under the six-month cadence the pace at which production-ready features and improvements are delivered has sharply increased.

The changes in JDK 23 range from significant new features to small enhancements to routine maintenance, bug fixes, and documentation improvements. Each change is represented in a single commit for a single issue in the JDK Bug System.

Of the 28,724 JIRA issues marked as fixed in Java 11 through Java 23 at the time of their GA, 20,450 were completed by people working for Oracle while 8,274 were contributed by individual developers and developers working for other organizations. Going through the issues and collating the organization data from assignees results in the following chart of organizations sponsoring the development of contributions in Java:

Issues fixed in JDK 11-JDK 23 per organization

In Java 23, of the 2,277 JIRA issues marked as fixed, 1,608 were completed by Oracle, while 669 were contributed by other members of the Java community.

Issues fixed in JDK 23 per organization

Oracle would like to thank the developers working for organizations including Alibaba, Amazon, Google, IBM, Intel, ISCAS, Microsoft, Red Hat, Rivos, SAP and Tencent for their notable contributions. We are also thankful to see contributions from smaller organizations such as Ampere Computing, Bellsoft, Loongson and NTT Data, as well as independent developers who collectively contributed 5% of the fixes in Java 23.

Additionally, we would like to thank the following individuals who provided invaluable feedback on build quality, logged good quality bugs, or offered frequent updates:

  • Sanne Grinovero (Hibernate projects)
  • Yoann Rodière (Hibernate projects)
  • Stefano Cordio (AssertJ)
  • Rich Hillegas (Apache Derby)
  • Chris Hegarty (Elastic)

Further, through the OpenJDK Quality Outreach program we would like to thank the following FOSS projects and individuals who provided excellent feedback on testing Java 23 early access builds to help improve the quality of the release:

  • Apache Ant (Jaikiran Pai)
  • Apache Commons (Benedikt Ritter)
  • Avaje (Josiah Noel)
  • BNYMellon CodeKatas (Emilie Robichaud)
  • JobRunr (Ronald Dehuysser)
  • RxJava (David Karnok)

Resources

Java continues to be the #1 programming language for today’s technology trends. As the on-time delivery of improvements with Java 23 demonstrates, through continued thoughtful planning and ecosystem involvement, the Java platform is well-positioned for modern development and growth in the cloud.

Keep up with news and updates by:

  • Visiting Dev.java (Oracle’s dedicated portal to advance your Java knowledge and community participation).
  • Visiting Inside.java (news and views by the Java Team at Oracle).
  • Listening to the Inside.java podcasts (an audio show for Java Developers brought to you directly from the people that make Java at Oracle).
  • Listening to the Duke’s Corner Podcast (an audio show that features the personal stories, experiences and expertise of Java community luminaries).
  • Watching Inside.java Newscasts (a video show extending the Inside.java podcast).
  • Watching Java on YouTube (Oracle’s Java videos to help grow your Java expertise).
  • Watching JEP Café (Oracle’s technical exploration into popular JDK Enhancement Proposals).
  • Watching Sip of Java (Oracle’s 1-minute shorts offering introductions into lesser known Java enhancements).
  • Joining the OpenJDK mailing lists (to learn about the progress of your favorite OpenJDK projects).
  • Following OpenJDK and Java on X.
  • Subscribing to the Inside Java Newsletter (a monthly publication summarizing many of the key Java technology and community updates from Oracle).