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 JDK releases.
Significant Changes in JDK 23 Release
See JDK 23 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 23.
The following are some of the updates in Java SE 23 and JDK 23:
Language Preview Features
- Pattern matching is now enhanced by allowing primitive type patterns in all pattern contexts. The
instanceof
andswitch
operators, expressions, and statements work with all primitive types.See JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) and the following sections in Java Platform, Standard Edition Java Language Updates:
- Module Import Declarations enable you to succinctly import all of the packages exported by a module with a module import declaration. It simplifies the reuse of modular libraries without requiring the imported code to be in a module.
See JEP 476: Module Import Declarations (Preview) and Module Import Declarations in Java Platform, Standard Edition Java Language Updates.
- Flexible Constructor Bodies enable you to add statements that don't reference the instance being created before an explicit constructor invocation. This feature helps you to prepare arguments for a superclass constructor by performing nontrivial computations or to validate arguments you want to pass to a superclass constructor.
See JEP 482: Flexible Constructor Bodies (Second Preview) and Flexible Constructor Bodies in Java Platform, Standard Edition Java Language Updates.
- Implicitly Declared Classes and Instance Main Methods enable students to write their first programs even without learning the full set of language features designed for large programs. Students can write streamlined declarations for single-class programs and then seamlessly expand their programs to use more advanced features as their skills grow.
See JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview) and Implicitly Declared Classes and Instance Main Methods in Java Platform, Standard Edition Java Language Updates.
- String Templates were first previewed in JDK 21 (JEP 430) and in JDK 22 (JEP 459). String templates were intended to be re-previewed in JDK 23 (JEP 465). However, after extensive feedback and discussion, we concluded that the feature is unsuitable in its current form. There is no consensus on what a better design will be; therefore, we have withdrawn the feature for now, and JDK 23 will not include it.
See March 2024 Archives by thread and Update on String Templates (JEP 459) from the Project Amber amber-spec-experts mailing list for further discussion.
See JEP 12: Preview Features and Preview Language and VM Features in Java Platform, Standard Edition Java Language Updates.
Library Improvements Previews and Incubator
- The Class-File API is used for parsing, generating, and transforming Java class files.
See JEP 466: Class-File API (Second Preview) and Class-File API in Java Platform, Standard Edition Java Virtual Machine Guide.
- Stream gatherers enable you to create custom intermediate operations, which allow stream pipelines to transform data in ways that aren't easily achievable with existing built-in intermediate operations.
See JEP 473: Stream Gatherers (Second Preview) and Stream Gatherers 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 480: Structured Concurrency (Third Preview) and Structured Concurrency in Java Platform, Standard Edition Core Libraries.
- 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 481: Scoped Values (Third Preview) and the
ScopedValue
class in the Java API Specification. - 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 469: Vector API (Eighth Incubator).
Runtime Improvements
- The ZGC garbage collector now runs in the generational mode by default. The non-generational mode of ZGC has been deprecated for removal. This will generally improve application performance, although a small number of workloads that are non-generational in nature may be impacted negatively.
See JEP 474: ZGC: Generational Mode by Default and the section The Z Garbage Collector in Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide.
- The Oracle GraalVM JIT compiler (Graal JIT) is now included among the JITs available as part of the Oracle JDK. This integration offers innovations previously made available through Oracle GraalVM, such as novel JIT code optimization techniques (see Compiler Advantages in the GraalVM documentation). This provides developers and system administrators more options to help fine tune and improve peak performance of their applications. The Graal JIT is enabled by passing the command line options to the Java executable:
-XX:+UnlockExperimentalVMOptions -XX:+UseGraalJIT
If you do not pass these flags at JVM startup, the Oracle JDK default JIT (C2) will run as usual.
Tooling
JavaDoc documentation comments can now be written in Markdown syntax along with HTML elements and JavaDoc tags.
See JEP 467: Markdown Documentation Comments and Markdown in Documentation Comments in Java Platform, Standard Edition JavaDoc Guide.
Removed APIs, Tools, and Components
For more details on removals and deprecations, see Features and Options Removed and Deprecated in JDK 23.
In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 23.
Significant Changes in JDK 22 Release
See JDK 22 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 22.
The following are some of the updates in Java SE 22 and JDK 22:
Language Features
- Unnamed variables and unnamed patterns can be used when variable declarations or nested patterns are required but never used. Unnamed patterns can appear in a pattern list of a record pattern and can be used instead of a type pattern. You denote both with the underscore character
(_)
.See JEP 456: Unnamed Variables & Patterns and Unnamed Variables and Patterns in Java Platform, Standard Edition Java Language Updates.
Preview Language Features
- In constructors, you can add statements that don't reference the instance being created before an explicit constructor invocation. You can use this feature to prepare arguments for a superclass constructor by performing nontrivial computations or validate arguments you want to pass to a superclass constructor.
See JEP 447: Statements before super(...) and Statements Before super(...) in Java Platform, Standard Edition Java Language Updates.
- String templates complement Java's existing string literals and text blocks by coupling literal text with embedded expressions and template processors to produce specialized results. Embedded expressions are Java expressions with additional syntax that differentiates them from the literal text in the string template. A template processor combines the literal text in the template with the values of the embedded expressions to produce a result.
See JEP 459: String Templates (Second Preview) and String Templates in Java Platform, Standard Edition Java Language Updates.
- The preview features Instance Main Methods and Implicitly Declared Classes enable students to write their first programs without needing to understand the full set of language features designed for large programs. They can write streamlined declarations for single-class programs and then seamlessly expand their programs to use more advanced features as their skills grow.
See JEP 463: Implicitly Declared Classes and Instance Main Methods (Second Preview) and Implicitly Declared Classes and Instance Main Methods in Java Platform, Standard Edition Java Language Updates.
See Preview Language and VM Features for more information about preview features.
Library Improvements
- The Foreign Function and Memory (FFM) 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, memory not managed by the JVM.
See JEP 454: Foreign Function & Memory API and Foreign Function and Memory API in Java Platform, Standard Edition Core Libraries.
Library Improvements Previews and Incubator
- Stream gatherers enable you to create custom intermediate operations, which allow stream pipelines to transform data in ways that aren't easily achievable with existing built-in intermediate operations.
See JEP 461: Stream Gatherers (Preview) and Stream Gatherers in Java Platform, Standard Edition Core Libraries.
- The Class-File API is used for parsing, generating, and transforming Java class files.
See JEP 457: Class-File API (Preview) and Class-File API in Java Platform, Standard Edition Java Virtual Machine Guide.
- 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 462: Structured Concurrency (Second Preview) and Structured Concurrency in Java Platform, Standard Edition Core Libraries.
- 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 464: Scoped Values (Second Preview) and the
ScopedValue
class in the Java API Specification. - 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 460: Vector API (Seventh Incubator).
See JEP 12: Preview Features and JEP 11: Incubator Modules for more information about preview features and incubating APIs.
Performance Improvements
Region pinning in G1 reduces latency so that garbage collection need not be disabled during Java Native Interface (JNI) critical regions.
See JEP 423: Region Pinning for G1 and the section Evacuation Failure in Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide.
Tooling
The Java application launcher is enhanced to run a program supplied as multiple files of Java source code. This will enable gradual transition from small programs to larger ones.
Removed APIs, Tools, and Components
For more details on removals and deprecations, see Features and Options Removed and Deprecated in JDK 22.
In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 22.
Significant Changes in JDK 21 Release
See JDK 21 Release Notes for additional descriptions of the new features and enhancements, and API specification in JDK 21.
The following are some of the updates in Java SE 21 and JDK 21:
Language Features
- Record patterns and type patterns can be nested to enable a
powerful, declarative, and composable form of data navigation and processing.
You can use a record pattern to test whether a value is an instance of a record
class type and, if it is, to recursively perform pattern matching on its
component values. In this release, support for record patterns appearing in the
header of an enhanced
for
statement has been removed.See JEP 440: Record Patterns and Record Patterns in Java Platform, Standard Edition Java Language Updates.
- A
switch
statement transfers control to one of several statements or expressions, depending on the value of its selector expression. Extending pattern matching toswitch
allows 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. In this release:- Parenthesized patterns have been removed.
- Qualified
enum
constants ascase
constants inswitch
expressions and statements are allowed.
See JEP 441: Pattern Matching for switch and Pattern Matching for switch Expressions and Statements in Java Platform, Standard Edition Java Language Updates.
Preview Language Features
- String templates complement Java's existing string literals and text blocks by
coupling literal text with embedded expressions and template processors to
produce specialized results.
See JEP 430: String Templates (Preview) and String Templates in Java Platform, Standard Edition Java Language Updates.
- Unnamed patterns match a record component without stating the component's name
or type. Unnamed variables are variables that can be initialized but not used.
You denote both with the underscore character (
_
).See JEP 443: Unnamed Patterns and Variables (Preview) and Unnamed Patterns and Variables in Java Platform, Standard Edition Java Language Updates.
- Unnamed classes and instance main methods enable students to write streamlined
declarations for single-class programs and then seamlessly expand their programs
later to use more advanced features as their skills grow.
See JEP 445: Unnamed Classes and Instance Main Methods (Preview) and Unnamed Classes and Instance Main Methods in Java Platform, Standard Edition Java Language Updates.
See Preview Language and VM Features for more information about preview features.
Library Improvements
- Virtual threads are lightweight threads that reduce the effort of writing,
maintaining, and debugging high-throughput concurrent applications.
See JEP 444: Virtual Threads and Virtual Threads in Java Platform, Standard Edition Core Libraries.
- Sequenced collections are collections with a defined encounter
order. Each such collection has a well-defined first element, second element,
and so forth, up to the last element. It is an interface that represents a
sequenced collection, provides uniform APIs for accessing its first and last
elements, and for processing its elements in reverse order.
See JEP 431: Sequenced Collections and Creating Sequenced Collections, Sets, and Maps in Java Platform, Standard Edition Core Libraries.
- The Key Encapsulation Mechanism API is introduced for key
encapsulation mechanisms (KEMs), an encryption technique for securing symmetric
keys using public key cryptography.
See JEP 452: Key Encapsulation Mechanism API and The KEM Class in Java Platform, Standard Edition Security Developer's Guide.
Library Improvements Previews and Incubator
- The preview API Foreign Function and Memory API has been further
refined as follows:
- Centralized the management of the lifetimes of native
segments in the
Arena
interface - Enhanced layout paths with a new element to dereference address layouts
- Provided a linker option to optimize calls to functions
that are short-lived and will not upcall to Java (e.g.,
clock_gettime
) - Provided a fallback native linker implementation, based on
libffi
, to facilitate porting - Removed the
VaList
class
- Centralized the management of the lifetimes of native
segments in the
- 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 453: Structured Concurrency (Preview) and Structured Concurrency in Java Platform, Standard Edition Core Libraries.
- 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 446: Scoped Values (Preview) and the
ScopedValue
class in the Java API Specification. - 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 448: Vector API (Sixth Incubator).
See JEP 12: Preview Features and JEP 11: Incubator Modules for more information about preview features and incubating APIs.
Performance Improvements
Application performance has been improved by extending the Z Garbage Collector (ZGC) to maintain separate generations for young and old objects. This will allow ZGC to collect young objects, which tend to die young, more frequently.
See JEP 439: Generational ZGC and The Z Garbage Collector in Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide.
Stewardship
Warnings are issued when agents are loaded dynamically into a running JVM. These warnings aim to prepare users for a future release which disallows the dynamic loading of agents by default in order to improve integrity by default.
See JEP 451: Prepare to Disallow the Dynamic Loading of Agents.
Removed APIs, Tools, and Components
For more details on removals and deprecations, see Features and Options Removed and Deprecated in JDK 21.
In addition, there are security related updates that you need to be aware of. See Security Updates in JDK 21.
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.
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
- The new command-line tool
jwebserver
enables you to start a minimal web server that serves static files. This tool is useful for prototyping and testing. See JEP 408: Simple Web Server. - A
@snippet
tag is added to JavaDoc's Standard Doclet, which simplifies the inclusion of example source code in API documentation. See JEP 413: Code Snippets in Java API Documentation and Programmer's Guide to Snippets.
Library Changes
- UTF-8 is now the default charset for the Java SE APIs. With this change, APIs that depend on the default charset will behave consistently across all implementations, operating systems, locales, and configurations. See JEP 400: UTF-8 by Default and Be Aware Of The Default Charset.
- A service-provider interface (SPI) is defined for the host name and
address resolution, so that
java.net.InetAddress
can make use of resolvers other than the platform's built-in resolver. See JEP 418: Internet-Address Resolution SPI. See also the section Specify Mappings from Host Names to IP Addresses in Java Platform, Standard Edition Core Libraries for information about thejdk.net.hosts.file
system property, which enables you to configure InetAddress to use a specifichosts
file, rather than the system-wide resolver, to map host names to IP addresses. - Core reflection with method handles has been reimplemented. This
will reduce the maintenance and development cost of both the
java.lang.reflect
andjava.lang.invoke
APIs. See JEP 416: Reimplement Core Reflection with Method Handles.
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.
- The preview feature Pattern Matching for
switch
Expressions and Statements has been re-previewed in this release. This feature allows 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 420: Pattern Matching for switch (Second Preview) and Pattern Matching for switch Expressions and Statements in Java Platform, Standard Edition Java Language Updates. - The Foreign Function and Memory API, which was introduced in Java SE 17, allows Java programs to interoperate with code and data outside of the Java runtime. The API is re-incubated in this release along with enhancements. See JEP 419: Foreign Function & Memory API (Second Incubator).
- The Vector API was introduced in Java SE 16 as an incubating API. In this release the API is re-incubated with enhancements and performance improvements. See JEP 417: Vector API (Third Incubator).
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
- Applications can now configure context-specific and dynamically selected deserialization filters using a JVM-wide filter factory, which is invoked to select a filter for each individual deserialization operation. See JEP 415: Context-Specific Deserialization Filters and Serialization Filtering in Java Platform, Standard Edition Core Libraries guide.
- New interface types and implementations for pseudo-random number generators (PRNGs) are now available, including jumpable PRNGs and an additional class of splittable PRNG algorithms (LXM). See JEP 356: Enhanced Pseudo-Random Number Generators and Pseudorandom Number Generators in Java Platform, Standard Edition Core Libraries guide.
- New Java 2D internal rendering pipeline for macOS is implemented using the Apple Metal API. This is an alternative to the existing pipeline, which uses the deprecated Apple OpenGL API. See JEP 382: New macOS Rendering Pipeline.
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
- The Security Manager and APIs related to it have been deprecated for removal in a future release. See JEP 411: Deprecate the Security Manager for Removal.
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.
- Pattern matching for
switch
expressions and statements is introduced in this release. This feature allows 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 406: Pattern Matching for switch (Preview) and Pattern Matching for Switch Expressions and Statements in Java Platform, Standard Edition Java Language Updates guide. - Foreign Function & Memory API allows Java programs to interoperate with code and data outside of the Java runtime. See JEP 412: Foreign Function & Memory API (Incubator).
- The Vector API was introduced in Java SE 16 as an incubating API. In this release, enhancements have been incorporated along with performance improvements. See JEP 414: Vector API (Second 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 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:
- The Java programming language is enhanced with pattern matching for
the
instanceof
operator. This feature allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely. See JEP 394: Pattern Matching for instanceof and Pattern Matching for instanceof in Java Platform, Standard Edition Java Language Updates guide. - Records, first previewed in Java SE 14, is a permanent feature in this release. The earlier restrictions have been relaxed whereby the inner classes can declare members that are either explicitly or implicitly static. This includes record class members, which are implicitly static. See JEP 395: Records and Record Classes in Java Platform, Standard Edition Java Language Updates guide.
- By default, all internal elements of the JDK are strongly
encapsulated, except for critical internal APIs such as
sun.misc.Unsafe
. You can choose the relaxed strong encapsulation that has been the default since JDK 9. See JEP 396: Strongly Encapsulate JDK Internals by Default and Strong Encapsulation in the JDK. - UNIX domain socket channels have been integrated into JDK 16. See JEP 380: Unix-Domain Socket Channels and Internet Protocol and UNIX Domain Sockets NIO Example in Java Platform, Standard Edition Core Libraries.
- The Z Garbage Collector processes the thread stacks concurrently. This allows all roots in the JVM to be processed by ZGC in a concurrent phase. See JEP 376: ZGC: Concurrent Thread-Stack Processing and The Z Garbage Collector in Java Platform, Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide.
- The
jpackage
tool, which was incubated in JDK 14, is now a permanent feature. The tool packages a Java application into a platform-specific package that includes the necessary dependencies. See JEP 392: Packaging Tool and Java Platform, Standard Edition Packaging Tool User's Guide. - Elastic metaspace overhauls the VM-internal metaspace- and class-space-implementation. The unused HotSpot class-metadata (that is metaspace) memory is returned to the operating system. It reduces the metaspace footprint and simplify the metaspace code in order to reduce maintenance costs. See JEP 387: Elastic Metaspace.
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
, andpermits
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.
- Sealed Classes is a Java language preview feature. Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them. See JEP 360: Sealed Classes (Preview) and Sealed Classes in Java Platform, Standard Edition Java Language Updates guide.
- Pattern Matching for
instanceof
, a preview feature from Java SE 14, is re-previewed for this release. This feature allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely. See JEP 375: Pattern Matching for instanceof (Second Preview) and Pattern Matching for the instanceof in Java Platform, Standard Edition Java Language Updates guide. - Records, a preview feature from Java SE 14, is re-previewed for this release. Records are classes that act as transparent carriers for immutable data. See JEP 384: Records (Second Preview) and Record Classes in Java Platform, Standard Edition Java Language Updates guide.
- The Foreign Memory Access API allows Java programs to efficiently and safely access foreign memory outside of the Java heap. See JEP 383: Foreign-Memory Access API (Second 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 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 newcase ... ->
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 createMappedByteBuffer
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
Records
is a Java language preview feature, which provides a compact syntax for declaring classes that are transparent holders for shallowly immutable data. See JEP 359: Records (Preview).- Pattern Matching for
instanceof
is a Java language preview feature that simplifies theinstanceof-and-cast
idiom. See JEP 305: Pattern Matching for instanceof (Preview). - Text blocks are multi-line string literals that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over the format when desired. Text Blocks were introduced in JDK 13 as a Preview Feature. Text Blocks is being previewed again in JDK 14 with the addition of two new escape sequences. See JEP 368: Text Blocks (Second Preview).
jpackage
, a simple tool for packaging self-contained Java applications. See JEP 343: Packaging Tool (Incubator).- An API that allows Java programs to efficiently access foreign memory outside of the Java heap is introduced. See JEP 370: Foreign-Memory Access API (Incubator).
- The Z Garbage Collector (ZGC), previously available only for Linux, is introduced as an experimental feature on Windows and macOS. See JEP 364: ZGC on macOS and JEP 365: ZGC on Windows.
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:
- Dynamic CDS Archiving extends application class-data sharing (ApsCDS), which allows dynamic archiving of classes when the Java application exits. See JEP 350: Dynamic CDS Archives.
- Text blocks were added to Java language, which provide developers with control over the format when desired. This is a preview language feature. See JEP 355 Text Blocks (Preview) and JEP 12: Preview Language and VM Features.
- The
switch
expression, a preview language feature, was extended to be used as either a statement or an expression, so that both forms can use either traditional labels (with fall through) or new labels (with no fall through). It is used with a further new statement for yielding a value from aswitch
expression. See JEP 354: Switch Expressions (Preview) and JEP 12: Preview Language and VM Features. - The implementation used by
java.net.Socket
andjava.net.ServerSocket
APIs was replaced with a simpler and more modern implementation that is easy to maintain and debug. See JEP 353: Reimplement the Legacy Socket API. - Support for Unicode 12.1. See Unicode 12.1.
- ZGC was enhanced to return unused heap memory to the operating system, which enhances the memory footprint of the applications. See JEP 351 ZGC Uncommit Unused Memory.
Significant Changes in JDK 12 Release
The following were some of the important additions and updates in Java SE 12 and JDK 12:
- JVM Constants API was introduced to model nominal descriptions of key class-file and run-time artifacts, in particular constants that were loadable from the constant pool. See JVM Constant API.
- The
switch
statement was extended so that it can be used either as a statement or an expression. This is a preview language feature. See JEP 325: Switch Expressions (Preview) and JEP 12: Preview Language and VM Features. - Support for Unicode 11.0. See Unicode 11.0.
- Square character support was provided for the Japanese Reiwa Era, which began on May, 2019. See Square character support.
- The
NumberFormat
added support for formatting a number in its compact form. See Compact Number Formatting Support .
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:
-
Oracle no longer offers JRE and Server JRE downloads; consequently, Auto-Update is not available anymore.
-
Java Web Start, Java Plugin, and Java Control Panel are not available in JDK. See Removal of the Deployment Stack.
-
JavaFX is no longer included in the JDK. It is now available as a separate download from https://openjfx.io/.
-
JAXB and JAX-WS are no longer bundled with JDK. See Removal of Java EE and CORBA Modules.