What is new in Java 19 ?

March 27, 2022

Introduction

This is a post of what will become Java 19 and it will change over time until the development of Java 19 is frozen in 2022.

Reminder 1: If something is implemented in an incubator module, it is not a permanent feature and it is released to get feedback from developers. API in such a module may change or completely removed (not released in any future JDK release). You need to use --add-modules to use incubator modules.

Reminder 2: If something is a preview feature, it is fully specified and implemented, but provided in a release to gather feedback, so it is not a permanent change yet. You need to use --enable-preview to use such features.

Changes

  • 2022/10/13: JEP 428 added to the blog post.
  • 2022/09/20: Java 19 is released.
  • 2022/05/29: JEP 405, 424, 426.
  • 2022/05/02: JEP 426.
  • 2022/03/27: First post.

Java 19 Features

The list is taken from the OpenJDK JDK 19 project page.

JEP 405: Record Patterns (Preview)

The goal of this JEP is to extend instanceof type and pattern matching pattern introduced with JEP 394 to record classes. So it will be possible to check both the type and then match and deconstruct a record class like if (o instanceof Point(int x, int y).

JEP 422: Linux/RISC-V Port

The RISC-V port of JDK which is nearly complete will be integrated into the mainline JDK.

JEP 424: Foreign Function & Memory API (Preview)

This one is interesting because it replaces two previous incubating APIs, the Foreign-Memory Access API and Foreign Linker API, and it became a preview feature not incubating. The goal of this JEP is basically to provide an easier to use and more general API to work with code and data outside of JVM.

JEP 425: Virtual Thrads (Preview)

This preview feature introduces the concept of a lightweight Virtual Thread that is not backed by an OS Thread. The OS Thread concept is then called Platform Thread. Virtual Thread provides a mechanism to implement thread per request or async programming style.

JEP 426: Vector (API) (Fourth Incubator)

The fourth iteration of the Vector API which is first introduced in Java 16.

JEP 427: Pattern Matching for switch (Third Preview)

The third preview of this feature which is first shown in Java 17.

JEP 428: Structured Concurrency (Incubator)

This JEP is to simplify multithreaded programming by introducing Structured Concurrency.