What's New in Java 20?
Table of Contents

What's New in Java 20?


Java 20 was officially released with the introduction of its general availability on March 21, 2023. This is the 10th release of the language, that followed the six-month release window that has become standard. That is why we know the next release, Java 21, is expected to be available in September 2023.  

While Java 19 introduced groundbreaking virtual threads, Java 20 is a smaller version in terms of new features. The main new feature in Java 20 is 'Scoped Values', which is intended to replace thread-local variables. In addition to this, it contains a total of six JDK Enhancement Proposals called JEPs, all of which are incubator or preview features. This means that these features are still in development and must be explicitly enabled via the '--enable-preview' option in the java and javac commands to be tested. The six JEPs that come with this release are divided into three groups, which correspond to Project Amber (aimed at increasing developer productivity), Project Loom (aimed at reimagining threading), and Project Panama (aimed at combining Java with other platforms). In addition to these categories, there is also another JEP that focuses on vector math.  

Project Amber

Record patterns (JEP 432)

In its second preview, record patterns introduce a new set of patterns to deconstruct record values, enhancing the Java programming language.  

Record patterns and type patterns can be nested, allowing for declarative and powerful data navigation and processing. The primary objective is to extend pattern matching capabilities to express more sophisticated and composable data queries without changing the syntax or semantics of type patterns. The significant changes made since the first preview in JDK 19 include adding support for inference of type arguments of generic record patterns, enabling record patterns to appear in the header of an enhanced for statement, and the removal of support for named record patterns.

Pattern matching for switch (JEP 433)

Pattern matching for switch statements and expressions provides a concise and secure method for expressing complex data-oriented queries. This feature was previously previewed in JDK 17, JDK 18, and JDK 19. In the fourth preview, it continues to evolve alongside Record Patterns, allowing for further refinements based on feedback and experience.  

The key changes in pattern matching for switch statements since the third preview include simplified grammar for switch labels and support for type argument inference for generic patterns and record patterns in switch statements and expressions. Additionally, an exhaustive switch over an enum class now throws a MatchException instead of an IncompatibleClassChangeError if no switch label applies at runtime.

Project Loom

Scoped values (JEP 429)

Currently, in the incubation stage of development, the Scoped Values API facilitates the sharing of immutable data within and between threads. This approach is preferred over thread-local variables, especially in situations with a high number of virtual threads. With scoped values, data can be safely and efficiently shared among various components in a large program without relying on method arguments. The primary objectives of this API are to provide ease of use, comprehensibility, robustness, and high performance.

Virtual threads (JEP 436)

In its second preview, virtual threads are designed as lightweight threads that significantly reduce the effort required for writing, maintaining, and observing high-throughput concurrent applications. According to Oracle, this feature will fundamentally transform the way Java applications are scaled. Minor changes have been made since the first preview in JDK 19, including a few permanent API changes in JDK 19 and downgrades to ThreadGroup, also made permanent in JDK 19.

Structured concurrency (JEP 437)

Structured concurrency provides an API to simplify multithreaded programming by treating multiple tasks running in different threads as a single unit of work. This approach streamlines error-handling and cancellation, enhancing both reliability and observability. The only modification since the feature was incubated in JDK 19 is the update to StructuredTaskScope, which now supports the inheritance of scoped values by threads created in a task scope. This feature is being re-incubated.

Project Panama

Foreign function and memory API (JEP 434)

The Foreign Function and Memory API introduces an interface that allows Java programs to interact with code and data outside of the Java runtime. With this API, Java programs can call native libraries and process native data without the risks and limitations of JNI (Java Native Interface). The API was previously under incubation in JDK versions 17 and 18 and previewed in JDK 19. Refinements have been made since then, such as the unification of MemorySegment and MemoryAddress abstractions, an improved MemoryLayout hierarchy, and the division of MemorySession into Arena and SegmentScope, which enables the sharing of segments across maintenance boundaries.

One more JEP

Vector API (JEP 438)

Recently, the vector API proposal was officially added, providing an API to express vector computations that can compile at runtime as optimal vector instructions on supported CPU architectures. By utilizing this API, superior performance can be achieved compared to equivalent scalar computations. The vector API has been incubated in JDK 16, JDK 17, JDK 18, and JDK 19.

Deprecation / Deletions

  1. java.net.URL constructors are deprecated
  1. Thread.suspend/resume changed to throw UnsupportedOperationException

Smaller changes in Java 20

  1. Javac Warns about Type Casts in Compound Assignments with Possible Lossy Conversions
  1. Idle Connection Timeouts for HTTP/2
  1. HttpClient Default Keep Alive Time is 30 Seconds
  1. IdentityHashMap's Remove and Replace Methods Use Object Identity
  1. The new method Path::getExtension returns the file’s extension
  1. Datagram Transport Layer Security (DTLS) key exchange named groups
  1. The addition of a new GarbageCollectorMXBean to report the occurrence and duration of remark and cleanup pause times for the G1 garbage collector
  1. ChaCha20 intrinsics on x86_64 and aarch64 platforms
  1. Support for Unicode 15.0
  1. Improved control of G1’s concurrent refinement threads
  1. Support for Unicode CLDR version 42
  1. New JDK Flight Recorder events: jdk.InitialSecurityProperty and jdk.SecurityProviderService
  1. Improvements to the Preview API page in the documentation generated by Javadoc
  1. New jmod –compress command-line option
  1. Grapheme support in Break Iterator
  1. Updated time zone data that complies with the 2022c standard
  1. Auto Generated IDs in Javadoc headings


The main benefit of the latest version of Java is the introduction of 'Scoped Values', which provides a beneficial tool for assigning a read-only, thread-specific value to a thread or group of child threads for their lifetime.

Other changes in Java 20 are mostly slightly modified and improved versions of already introduced JEPs, as well as minor improvements, routine maintenance, and bug fixes.

While the changes introduced in the updated version of Java may not seem groundbreaking, they do offer some significant improvements to the platform. Moreover, these changes provide an insight into the evolution of the Java language and give us some idea of what to expect from Java 21, which is likely to be a more groundbreaking release as it will carry the LTS tag that Oracle will support for the next five years.  

Even though this release will not phase out Java 8’s adoption, each release brings us closer to the date it will inevitably happen.

Liked the article? subscribe to updates!
360° IT Check is a weekly publication where we bring you the latest and greatest in the world of tech. We cover topics like emerging technologies & frameworks, news about innovative startups, and other topics which affect the world of tech directly or indirectly.

Like what you’re reading? Make sure to subscribe to our weekly newsletter!

Join 17,850 tech enthusiasts for your weekly dose of tech news

By filling in the above fields and clicking “Subscribe”, you agree to the processing by ITMAGINATION of your personal data contained in the above form for the purposes of sending you messages in the form of newsletter subscription, in accordance with our Privacy Policy.
Thank you! Your submission has been received!
We will send you at most one email per week with our latest tech news and insights.

In the meantime, feel free to explore this page or our Resources page for eBooks, technical guides, GitHub Demos, and more!
Oops! Something went wrong while submitting the form.

Related articles

Our Partners & Certifications
Microsoft Gold Partner Certification 2021 for ITMAGINATION
ITMAGINATION Google Cloud Partner
© 2024 ITMAGINATION. All Rights Reserved. Privacy Policy