BreadcrumbHomeResourcesBlog Java 20: What’s New In JDK 20 April 28, 2023 Java 20: What’s New in JDK 20Java ToolsJava 20 was released in March 2023 and the features included are either incubator features that are not fully mature yet, or preview versions of various capabilities, including virtual threads and structured concurrency.Although this release doesn’t come with major updates, we expect Java users to continue transitioning away from legacy Java versions and into the new technologies within the Java ecosystem. In fact, according to our Java Developer Productivity Report*, 40% of respondents are on Java 17 or a more recent version. Let’s take a look at the new Java 20 features and what value they bring to Java development.*The 2024 Java Developer Productivity Report is here.See what's new in Java trends. Table of ContentsNew Features in Java 20Virtual Threads in Java 20Vector API in Java 20Structured Concurrency in Java 20Scoped Values in Java 20Foreign Function and Memory API in Java 20Record Patterns in Java 20Pattern Matching for Switch Statements and Expressions in Java 20Final Thoughts on Java 20 Table of Contents1 - New Features in Java 202 - Virtual Threads in Java 203 - Vector API in Java 204 - Structured Concurrency in Java 205 - Scoped Values in Java 206 - Foreign Function and Memory API in Java 207 - Record Patterns in Java 208 - Pattern Matching for Switch Statements and Expressions in Java 209 - Final Thoughts on Java 2010 - Back to topNew Features in Java 20This short-term Java release will be supported for six months following the September 20, 2022 release of JDK 19. We anticipate the long-term support (LTS) release of Java 21, due in September, to provide even greater updates backed by years of support. Until then, let’s dive into the new features in Java 20. Seven features have been officially marked for the Java 20 release, including: virtual threads, a vector API proposal, structured concurrency, scoped values, a foreign function and memory API, record patterns, pattern matching for switch statements and expressions, and a vector API proposal.📚 Java 23 is here! Read about permanent and proposed enhancements in the JDK. Back to topVirtual Threads in Java 20Virtual Threads are a prerequisite for structured concurrency. Since the first preview in Java 19, minor changes have been made, including a small number of API changes, as well as degradations to ThreadGroup. Now in the second preview stage, these lightweight threads reduce the effort of writing and maintaining concurrent applications. According to Oracle, this will radically change how Java applications are scaled. Back to topVector API in Java 20Previously, the Vector API was incubated in JDK 16, JDK 17, JDK 18, and JDK 19. This new API proposal was added a few weeks before the launch of Java 20 as a re-incubation, with no changes in the API relative to Java 19. The implementation includes a small number of bug fixes and performance enhancements, including the ability to express vector computations that reliably compile at runtime and act as optimal vector instructions on supported CPUs.Back to topStructured Concurrency in Java 20Delivered in Java 19 as an incubating API, Structured Concurrency works by treating multiple tasks running in different threads as a single unit of work. This helps streamline error handling and cancellation, thereby improving reliability and enhancing observability. The only change with its re-incubation is StructuredTaskScope being updated to support the inheritance of scoped values by threads created in a task scope. Back to topScoped Values in Java 20Scoped Values enable immutable data to be shared across and within threads. They’re preferred to thread-local variables, especially when used with a large number of virtual threads. Goals of this incubating API include ease of use, comprehensibility, robustness, and performance.Back to topForeign Function and Memory API in Java 20The Foreign Function and Memory (FFM) API combines two earlier incubating APIs: the Foreign-Memory Access API and the Foreign Linker API. The FFM API was first incubated in Java 17 before being re-incubated in Java 18; it was then first previewed in Java 19. Based on user feedback, Java 20 re-previews the FFM API to include the following refinements: MemorySegment and MemoryAddress abstractions are unified (memory addresses are now modeled by zero-length memory segments)Sealed MemoryLayout hierarchy is enhanced to facilitate usage with pattern matching in switch expressions and statementsMemorySession has been split into Arena and SegmentScope to facilitate sharing segments across maintenance boundariesBack to topRecord Patterns in Java 20The main goals of the second preview of Record Patterns are to extend pattern matching to express more sophisticated, composable data queries, as well as to maintain the syntax or semantics of type patterns. Since the first preview of this language feature delivered in Java 19, expect the following changes in Java 20: added support for inference of type arguments of generic record patterns, support for record patterns to appear in the header of an enhanced for statement, and removal of support for named record patterns.Back to topPattern Matching for Switch Statements and Expressions in Java 20Pattern Matching was initially proposed as a preview and delivered in Java 17, proposed for a second preview and delivered in Java 18, and proposed for a third preview and delivered in Java 19. This language feature’s fourth preview in Java 20 enables its continued co-evolution with the Record Patterns preview feature, and includes basic updates to grammar around switch statements.⚠️ Java 20 is not a Java LTS version. Learn more about Java LTS. Back to topFinal Thoughts on Java 20Java 20 features are moving toward becoming more standardized, and these features are determined by various Java research projects. While Java 20 doesn't introduce any new JEPs or major updates, it still has multiple preview and incubator features worth testing and leaving feedback on. For a full list of all Java 20 features, check out the release notes.When it comes to Java, JRebel is just what you need to help maximize your productivity. The latest JRebel release includes added support for new Java technology versions, including Java 20. See how much time your team could save during your 14-day free trial. TRY JREBEL Back to top