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
switch
Expressions and Statements has been further refined as follows:- An exhaustive switch (that is, a
switch
expression or a patternswitch
statement) over anenum
class throws aMatchException
instead of anIncompatibleClassChangeError
if noswitch
label applies at run time. - The grammar for
switch
labels is simpler. - The compiler can infer the type of the type arguments for generic record
patterns in all constructs that accept patterns:
switch
statements and expressions,instanceof
expressions, and enhancedfor
statements.
- 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
for
statement. - 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
MemorySegment
andMemoryAddress
abstractions are unified (memory addresses are now modeled by zero-length memory segments). - The sealed
MemoryLayout
hierarchy is enhanced to facilitate usage with pattern matching in switch expressions and statements. See Pattern Matching for switch Expressions and Statements. MemorySession
has been split into Arena andSegmentScope
to 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.