What's Coming in Java 18

The newest version of Java is roughly around six months away right now. The release is starting to take shape with two very good, important feature proposals so far. They are record and array patterns and character sets.

[Read More! Java 17 is Officially Released]

As of right now, the OpenJDK page for Java Development Kit (JDK) 18 lists no official features to come yet, but the JEP (JDK Enhancement Proposal) index of Java Technologies cites two features proposed for Java 18:

  • A preview of record patterns and array patterns, in which the Java language would be enhanced with record patterns, to deconstruct record values, and array pattens, to deconstruct array values. Record patterns, array patterns, and type patterns, which were featured in JDK 16, can be nested so as to significantly enhance the expressiveness and utility of pattern matching. Goals of the proposal include extending pattern matching to express more sophisticated, composable data queries, and not changing the syntax or semantics of type patterns.
  • Specifying UTF-8 as the default charset of the standard Java APIs. UTF-8 is a variable-wide character encoding for electronic communication and is considered the web’s standard charset. Charset is character encoding capable of encoding all characters on the web. Through this change, APIs that depend on the default charset will behave consistently across all implementations, operating systems, locales, and configurations. The proposal is not intended to define new Java-standard or JDK-specific APIs. By specifying that UTF-8 is the default charset, there is risk that applications will not behave correctly when processing data produced when the new default charset is unspecified. This risk is not new. But applications in many environments can expect very low risk from UTF-8. MacOS, for example, has had UTF-8 as its default charset for several releases, except when configured to use the Posix C locale, the proposal states. Many Linux distributions also use UTF-8. In other environments, there may be significant risk in changing the default charset to UTF-8 after more than 20 years, with Windows users in Asian locales impacted as well as possibly some server environments in Asia and other locales.

The standard release cycle of Java’s six-month release cadence, the Java Development Kit 18 would arrive in around March 2022. Other potential features that are worth noting in JDK 18 include pattern matching for switch expressions and statements, which is being previewed in the upcoming JDK 17 release, as well as a vector API and a foreign function and memory API, both of which are in an incubator stage in JDK 17.

Java Development Kit 17 is due as a production release on September 14. Now in a release candidate stage, JDK 17 is set to be a long-term support release, with years of support, while JDK 18 would only receive six months of support, based on Oracle’s standard Java release pattern.