JDK 19 Release - Sip of JavaBilly Korando on September 20, 2022
Today, on September 20th, the newest version of the JDK, JDK 19, was released. This version of the JDK sees some long-anticipated features debut in the mainline JDK release. In this article, we will take a brief look at these new features and others included in JDK 19.
Project Loom is seeing two features being added to the mainline JDK release. Virtual Threads, JEP 425, is being added as a preview feature. Virtual threads are lightweight threads that the JVM is capable of parking when the thread is blocked. This will allow applications that heavily utilize threads, like web applications that often have one thread-per-request model, to scale much more effectively on modern hardware. This benefit is delivered while still using a blocking programming style Java developers are familiar with.
The other feature being delivered from Project Loom is Structured Concurrency, JEP 428, which is currently an incubator feature. Structured Concurrency provides an easy way to divide a unit of work into multiple tasks that can be executed across multiple threads simultaneously. The tasks will still be treated as a single unit of work and can have common handling for tasks that are complete, are canceled, or encounter an error.
There are two features from Project Panama that are a part of JDK 19. The Foreign Function and Memory API, JEP 424, moves into preview status with JDK 19. The Foreign Function and Memory API allows Java applications to interact with code and data outside the JVM, more safely than what is provided by the Java Native Interace (JNI).
The Vector API, JEP 426, enters its fourth incubation round. Provides superior performance when calculating vector instructions given the CPU architecture supports it. The Vector API will remain in incubation until features from project Valhalla are delivered.
The pattern matching story for Project Amber continues to pick up steam. Pattern matching for
switch will have a third preview, JEP 427. Key changes are
when clause being used instead of a guard
&& clause and improvements to
null case handling.
Record patterns were added as a preview feature with JEP 405. Record patterns will allow for the quick destructuring of data out of records. Record patterns and pattern matching for
switch are essential elements in Java’s data-oriented programming story.
The remaining JEP part of JDK 19 concerns the JDK being ported to the Linux/RISC-V architecture, JEP 422.
Finally, check out the release notes for JDK 19 under the additional reading section below. Several more additions, changes, and the usual bug fixes, security enhancements, etc., are part of the JDK 19 release.