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.