Significant Changes in JDK 20 Release
See JDK 20 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 20.
The following are some of the updates in Java SE 20 and JDK 20:
Concurrency Model Previews and Incubators
- Virtual threads are lightweight threads that reduce the effort of writing, maintaining, and debugging high-throughput concurrent applications. This is a preview API. Minor changes have been made to this API since the last release. See JEP 436: Virtual Threads (Second Preview) and Virtual Threads in Java Platform, Standard Edition Core Libraries.
- Structured Concurrency treats multiple tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability. See JEP 437: Structured Concurrency (Second Incubator). See JEP 11: Incubator Modules for more information about incubating APIs.
- Scoped values enables sharing of immutable data within and across threads. They are preferred to thread-local variables, especially when using large numbers of virtual threads. See JEP 429: Scoped Values (Incubator) and JEP 11: Incubator Modules.
- An API is introduced to express vector computations that reliably compile at runtime to optimal vector instructions on supported CPU architectures, thus achieving performance superior to equivalent scalar computations. See JEP 438: Vector API (Fifth Incubator).
Language Changes
- The preview feature Pattern Matching for
switchExpressions and Statements has been further refined as follows:- An exhaustive switch (that is, a
switchexpression or a patternswitchstatement) over anenumclass throws aMatchExceptioninstead of anIncompatibleClassChangeErrorif noswitchlabel applies at run time. - The grammar for
switchlabels is simpler. - The compiler can infer the type of the type arguments for generic record
patterns in all constructs that accept patterns:
switchstatements and expressions,instanceofexpressions, and enhancedforstatements.
- An exhaustive switch (that is, a
- The preview feature Record Patterns has been further refined as
follows:
- The compiler can infer the type of the type arguments for generic record patterns.
- Record patterns can appear in an enhanced
forstatement. - Named record patterns are no longer supported.
See Preview Language and VM Features for more information about preview features.
Library Changes
- The preview API Foreign Function and Memory API has been further
refined as follows:
- The
MemorySegmentandMemoryAddressabstractions are unified (memory addresses are now modeled by zero-length memory segments). - The sealed
MemoryLayouthierarchy is enhanced to facilitate usage with pattern matching in switch expressions and statements. See Pattern Matching for switch Expressions and Statements. MemorySessionhas been split into Arena andSegmentScopeto facilitate sharing segments across maintenance boundaries
- The
Removed APIs, Tools, and Components
For more details on removals and deprecations, see Features and Options Deprecated in JDK 20.
In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 20.