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 pattern switch statement) over an enum class throws a MatchException instead of an IncompatibleClassChangeError if no switch 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 enhanced for statements.
    See JEP 433: Pattern Matching for switch (Fourth Preview) and Pattern Matching for switch Expressions and Statements in Java Platform, Standard Edition Java Language Updates.
  • 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 JEP 432: Record Patterns (Second Preview) and Record Patterns in Java Platform, Standard Edition Java Language Updates.

See Preview Language and VM Features for more information about preview features.

Library Changes

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.