There were two major Java releases in 2022: Java 18 and Java 19. Java 17, released in 2021, was the last Long-Term Support release of the language, and the majority of developers tend to stick to LTS releases, according to various surveys of the ecosystem over the years. 

But still, it’s important to go over the additions in these last two releases.

Java 18 added nine new language enhancements, and Java 19 added seven. 

In Java 18, a new Simple Web Server was added that developers can use for prototyping and testing purposes. Chad Arimura, VP of developer relations at Oracle, explained that this addition continues on with the company’s efforts to make Java “more approachable for students and educators and developers that are just getting started in their careers.”

Developers can also add code snippets within API documentation to be able to provide better examples when documenting things. 

UTF-8 became the default charset for Java APIs, which means any APIs that are dependent on the default charset behave consistently on all implementations, operating systems, locales, and configurations.

Other features in Java 18 included method handling being made the underlying mechanism for reflection to reduce maintenance and development costs, and a new service-provider interface for host name and address resolution, enabling developers to use resolvers other than the built-in one. 

Features released in beta included a vector API, foreign function and memory API, pattern matching for switch expressions, and finalization is being prepared for removal in a future release and is currently deprecated.

Java 19 was the next major release, which came out in October. 

In that release, the most significant improvements to the language itself were the ability to nest record patterns and pattern matching for switch expressions, both of which are currently in preview. The record patterns update extends pattern matching and allows for more composable data queries. Pattern matching for switch expressions allows an expression to be tested against multiple patterns.

Library tool updates included an API for invoking foreign functions and accessing foreign memory safely, and a new Vector API that allows applications to express vector computations that compile at runtime to vector instructions.

New features that came out of Project Loom, which is an initiative to provide a lightweight concurrency model for Java, include virtual threads, which reduce the effort of writing, maintaining, and observing high-throughput concurrent applications, and structured concurrency, which simplifies multithreaded programming. 

The Linux/RISC-V Port was also integrated into the JDK mainline repository in that release. 

“Our ongoing collaboration with the developer community is the lifeblood of Java. As the steward of Java, Oracle is steadfastly committed to providing developers and enterprises with the latest tools to help them create innovative apps and services,” said Georges Saab, senior vice president of development for the Java Platform and chair of the OpenJDK Governing Board at Oracle, at the time of the release. “The powerful new enhancements in Java 19 are a testament to the monumental work across the global Java community.”