Java 18 is likely seven months away but is already starting to take shape, with two feature proposals for it so far: record and array patterns and character sets.
- 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 patterns, 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.
According to standard Java’s six-month release cadence, JDK 18 would arrive in March 2022. Other potential features targeting 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.
JDK 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 plans.