JDK 21: The new features in Java 21

Java 21 has arrived in a production release with 15 features including virtual threads, a generational Z garbage collector, and a key encapsulation mechanism API.

1 2 Page 2
Page 2 of 2

The production release of JDK 21 follows rampdown and release candidate stages dating back to June. As a long-term support release, JDK 21 would get five years of premier support and extended support until September 2031. The previous LTS release was JDK 17, published in September 2021. Non-LTS releases, such as JDK 20 and JDK 19, receive only six months of premier support and no extended support. LTS releases arrive every two years.

Many Java 21 features come from major, “named” Java development projects. Virtual threads, scoped values, and structured concurrency derive from Project Loom, a project focused on concurrency. String templates, record patterns, pattern matching for switch, unnamed patterns and variables, and unnamed classes and instance main methods come from Project Amber, which incubates smaller Java productivity features. The foreign function and memory API and vector API come to Java 21 from Project Panama, a project aimed at connecting Java and native code.

Oracle on September 19 announced it will now accept community contributions to Dev.java, which has featured tutorials from the Oracle team. The community at large can contribute through GitHub. Oracle also unveiled Java Playground, a REPL (read, extract, print loop) on Dev.java that allows developers to try out features of Java 21.

Copyright © 2023 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2