20.0.2

Latest release in branch Java SE 20
Released 2 years ago (18 Jul 2023)

Software Java/Java SE
Branch Java SE 20
Status
End of life
Java class file format major version 64.0
End of premier support Sep 2023
First official release version 20
First official release date 3 years ago (21 Mar 2023)
Release notes https://www.oracle.com/java/technologies/javase/20-0-2-relnotes.html
Documentation https://docs.oracle.com/javase/20
Download https://www.oracle.com/java/technologies/javase/jdk20-archive-downloads.html
Java/Java SE Java SE 20 Releases View full list

What Is New in Java 20

Java 20 delivers incremental updates with seven JDK Enhancement Proposals (JEPs) focused on evolving the platform. This release continues the development of preview and incubator features rather than introducing final, permanent changes.

Category Key Items
New Features / JEPs Scoped Values (Incubator), Record Patterns (Preview), Pattern Matching for switch (Preview), Foreign Function & Memory API (Preview), Virtual Threads (Preview), Structured Concurrency (Preview)
Improvements General performance and stability enhancements across the JDK
Deprecated/Removed Further deprecation of the legacy Applet API for removal

What are the main JEPs in Java 20?

Java 20 includes seven JEPs, primarily finalizing preview features from previous releases. This approach allows developers to test new capabilities without committing to a permanent API change.

Concurrency Updates

Virtual Threads (JEP 436) and Structured Concurrency (JEP 437) are in their second preview. They simplify writing and maintaining high-throughput concurrent applications. Scoped Values (JEP 429) is a new incubating API for sharing immutable data within a thread, designed as a modern alternative to ThreadLocal variables.

Language Enhancements

Record Patterns (JEP 432) and Pattern Matching for switch (JEP 433) enter their second and fourth previews, respectively. These features deconstruct record values and extend pattern matching, making data-oriented code more concise and readable.

Interoperability

The Foreign Function & Memory API (JEP 434) reaches its second preview, providing a pure-Java way to interoperate with native code and memory outside the JVM. This matters because it aims to replace the more error-prone JNI.

Is Java 20 a long-term support (LTS) release?

No, Java 20 is not an LTS release. It's a feature release with six months of support from Oracle. The current LTS version is Java 17; the next one will be Java 21.

In practice, this means most production systems will skip Java 20 and wait for the LTS release to adopt the stabilized features. You use non-LTS versions like JDK 20 to experiment with preview APIs and prepare for future migrations.

How do preview features work in Java 20?

Preview features are fully specified and implemented language or VM capabilities that are not yet permanent. You must explicitly enable them at compile and runtime to test them.

For example, to use Record Patterns, you need to add the --enable-preview flag. This mechanism allows the Java team to gather feedback before finalizing the design in a future release. Using them in production is not recommended as they can change or be removed.

FAQ

Should I upgrade my production application to Java 20?
Probably not. Since it's a non-LTS release, it's best used for development and testing preview features. For production, stick with Java 17 LTS unless you need a specific fix available only in JDK 20.

What is the difference between Virtual Threads and Platform Threads?
Virtual threads (JEP 436) are lightweight threads managed by the JVM, not the OS. They allow you to write synchronous, blocking code that scales with near-optimal hardware utilization, unlike costly platform threads which are OS kernel threads.

Can I use the new Foreign Function & Memory API instead of JNI?
Yes, that's the goal. JEP 434 provides a more efficient and safer Java API for interacting with native code and memory. It's still in preview, so it's perfect for prototyping but not yet for permanent production use without the preview flags.

Why is the Applet API being removed?
Web browser support for Java plugins has been completely removed for years, making the Applet API obsolete. Deprecating it for removal cleans up the JDK and reduces the maintenance burden for a dead technology.

How do Scoped Values improve upon ThreadLocal variables?
Scoped Values (JEP 429) are immutable and inherited by child threads within a defined scope. This makes them more efficient and less prone to memory leaks compared to mutable ThreadLocal variables, which can be cumbersome to manage correctly.

Releases In Branch Java SE 20

Version Release date
20.0.2 2 years ago
(18 Jul 2023)
20.0.1 3 years ago
(18 Apr 2023)
20 3 years ago
(21 Mar 2023)