2 Significant Changes in the JDK

Before migrating your application to the latest JDK release, you must understand what the updates and changes are between it and the previous JDK release. If you are migrating from JDK 8, you should also be familiar with the differences between JDK 8 and later releases that are described in Migrating From JDK 8 to Later JDK Releases.

See the following sections to learn about some of the significant changes in latest JDK releases.

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.

Significant Changes in JDK 19 Release

See JDK 19 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 19.

The following are some of the updates in Java SE 19 and JDK 19:

Concurrency Model Update Previews

  • Virtual threads are lightweight threads that reduce the effort of writing, maintaining, and debugging high-throughput concurrent applications. This is a preview API. See JEP 425: Virtual Threads (Preview) and Virtual Threads in Java Platform, Standard Edition Core Libraries.
  • An API is introduced to simplify multithreaded programming for structured concurrency. 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 428: Structured Concurrency (Incubator).

Language Changes

  • Record Patterns is introduced as a preview feature for this release. A record pattern consists of a type, a record component pattern list used to match against the corresponding record components, and an optional identifier. You can nest record patterns and type patterns to enable a powerful, declarative, and composable form of data navigation and processing. See JEP 405: Record Patterns (Preview) and Record Patterns in Java Platform, Standard Edition Java Language Updates.
  • The preview feature Pattern Matching for switch Expressions and Statements has been re-previewed in this release. This feature enables an expression to be tested against a number of patterns, each with a specific action, so that complex data-oriented queries can be expressed concisely and safely. See JEP 427: Pattern Matching for switch (Third Preview) and Pattern Matching for switch Expressions and Statements in Java Platform, Standard Edition Java Language Updates.

Library Changes

  • The Foreign Function and Memory API enables Java programs to interoperate with code and data outside the Java runtime. This API enables Java programs to call native libraries and process native data without the brittleness and danger of JNI. The API invokes foreign functions, code outside the JVM, and safely accesses foreign memory that is not managed by the JVM. This is a preview API. See JEP 424: Foreign Function & Memory API (Preview) and Foreign Function and Memory API in Java Platform, Standard Edition Core Libraries.
  • The Vector 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 426: Vector API (Fourth Incubator).

Removed APIs, Tools, and Components

For more details on removals and deprecations, see Features and Options Deprecated in JDK 19.

In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 19.

Significant Changes in JDK 18 Release

See JDK 18 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 18.

The following are some of the updates in Java SE 18 and JDK 18:

Tools

Library Changes

Preview Features and Incubator Modules

See JEP 12: Preview Features for more information about preview features and JEP 11: Incubator Modules for more information about incubator modules.

Removed APIs, Tools, and Components

For more details on removals and deprecations, see:

In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 18.

Significant Changes in JDK 17 Release

See JDK 17 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 17.

The following are some of the updates in Java SE 17 and JDK 17:

New Language Feature

  • Sealed Classes, first previewed in Java SE 15, is a permanent feature in this release. Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them. See JEP 409: Sealed Classes and Sealed Classes in Java Platform, Standard Edition Java Language Updates guide.

Library Changes

Other Changes

  • By default, all internal elements of the JDK are strongly encapsulated, except for critical internal APIs such as sun.misc.Unsafe. However, it will no longer be possible to relax the strong encapsulation of internal elements using a single command-line option, as it was possible in JDK 9 through JDK 16. See JEP 403: Strongly Encapsulate JDK Internals by Default.
  • The floating-point operations are now consistently strict, rather than having both strict floating-point semantics (strictfp) and subtly different default floating-point semantics. See JEP 306: Restore Always-Strict Floating-Point Semantics.

Deprecations

Preview Features and Incubator Modules

See JEP 12: Preview Features for more information about preview features and JEP 11: Incubator Modules for more information about incubator modules.

Removed APIs, Tools, and Components

See:

In addition, there are security related updates that you need to be aware of. See: Security Updates in JDK 17.

Significant Changes in JDK 16 Release

See JDK 16 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 16.

The following are some of the updates in Java SE 16 and JDK 16:

Preview Features and Incubator Modules

See Java Language Preview Feature for more information about preview features.

  • Sealed classes, a preview feature from JDK 15, is re-previewed in this release. Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them. There has been several refinements in this release, including the introduction of character sequences sealed, non-sealed, and permits as contextual keywords. See JEP 397: Sealed Classes (Second Preview) and Sealed Classes in Java Platform, Standard Edition Java Language Updates guide.
  • Initial iteration of an incubator module, jdk.incubator.vector, is provided to express vector computations. It reliably compiles at runtime to optimal vector hardware instructions on supported CPU architectures and thus achieve superior performance to equivalent scalar computations. See JEP 338: Vector API (Incubator).
  • Foreign Linker API is introduced that offers statically-typed, pure-Java access to native code. This API, along with the Foreign-Memory Access API (JEP 393), will simplify the otherwise error-prone process of binding to a native library. See JEP 389: Foreign Linker API (Incubator).
  • Foreign-Memory Access API allows Java programs to safely and efficiently access foreign memory outside of the Java heap. See JEP 393: Foreign-Memory Access API (Third Incubator).

Removed APIs, Tools, and Components

See:

In addition, there are security related updates that you need to be aware of. See: Security Updates in JDK 16.

Significant Changes in JDK 15 Release

See JDK 15 Release Notes for the complete list of new features and enhancements in JDK 15.

The following are some of the updates in Java SE 15 and JDK 15:

  • Text Blocks, first previewed in Java SE 13, is a permanent feature in this release and can be used without enabling preview features.

    Text blocks are multiline string literals that avoid the need for most escape sequences, automatically format the string in a predictable way, and give the developer control over the format when desired. See JEP 378: Text Blocks and Programmer's Guide to Text Blocks.

  • The Z Garbage Collector (ZGC) is ready to use in production and no longer an experimental feature. Enable ZGC by using the command-line option -XX:+UseZGC. See JEP 377: ZGC: A Scalable Low-Latency Garbage Collector (Production).
  • Hidden classes are classes that cannot be used directly by the bytecode of other classes. Hidden classes are intended for use by frameworks that generate classes at run time and use them indirectly through reflection. See JEP 371: Hidden Classes.

Preview and Incubator Features

See Java Language Preview Feature for more information about preview features.

Removed APIs, Tools, and Components

See:

In addition, there are security related updates that you need to be aware of. See: Security Updates in JDK 15.

Significant Changes in JDK 14 Release

The following are some of the changes in Java SE 14 and JDK 14:

  • Switch is extended so it can be used as either a statement or an expression, so that both forms can use either traditional case ... : labels (with fall through) or new case ... -> labels (with no fall through), with a further new statement for yielding a value from a switch expression. See JEP 361: Switch Expressions (Standard) and Java Language Changes.
  • G1 is enhanced to improve allocation performance on non-uniform memory access (NUMA) memory systems. See JEP 345: NUMA-Aware Memory Allocation for G1.
  • JDK Flight Recorder data is now available as a data stream allowing for continuous monitoring. See JEP 349: JFR Event Streaming.
  • New JDK-specific file mapping modes have been added so that the FileChannel API can be used to create MappedByteBuffer instances that refer to non-volatile (NVM) memory. See JEP 352: Non-Volatile Mapped Byte Buffers.
  • Allows currencies to be formatted with locale-specific accounting formats, for example, ($3.27) instead of -$3.27. See Accounting Currency Format Support.
  • Enhanced com.sun.management.OperatingSystemMXBean to ensure that it reports values based on the current operating environment, such as a container environment. The MXBean for tools to get information on the operating system has been improved for container environments. See OperatingSystemMXBean made container aware.

Experimental, Preview, and Incubator Features

Removed APIs, Tools, and Components

See:

In addition, there are security related updates that you need to be aware of. See: Security Updates in JDK 14.

Significant Changes in JDK 13 Release

The following were some of the important enhancements in Java SE 13 and JDK 13:

Significant Changes in JDK 12 Release

The following were some of the important additions and updates in Java SE 12 and JDK 12:

Significant Changes in JDK 11 Release

JDK 11 had some significant changes too. As JDK 11 is a long term support (LTS) release, you should be familiar with the following important changes in JDK 11 release: