Oracle announces Java 16

42

Oracle announced the availability of Java 16 (Oracle JDK 16) on Tuesday. The latest Java Development Kit (JDK) finalized Pattern Matching for instanceof (JEP 394) and Records (JEP 395), language enhancements that were first previewed in Java 14.  Additionally, developers can use the new Packaging Tool (JEP 392) to ship self-contained Java applications, as well as explore three incubating features, the Vector API (JEP 338), the Foreign Linker API (JEP 389), and the Foreign-Memory Access API (JEP 389), and one preview feature, Sealed Classes (JEP 397), the company said in a statement.

The new features delivered in Java 16 are:

Language Enhancements First Introduced in JDK 14, Finalized in JDK 16

  • JEP 394: Pattern Matching for instanceof – Enhances the Java programming language with pattern matching for the instanceof operator.
  • JEP 395: Records – Enhances the Java programming language with records, which are classes that act as transparent carriers for immutable data. Records can be thought of as nominal tuples.

New Tool to Improve Developer Productivity

  • JEP 392: Packaging Tool – Provides the jpackage tool, for packaging self-contained Java applications.

Improved Memory Management to Improve Performance

  • JEP 387: Elastic Metaspace – Returns unused HotSpot class-metadata (i.e., metaspace) memory to the operating system more promptly, reduces metaspace footprint, and simplifies the metaspace code in order to reduce maintenance costs.
  • JEP 376: ZGC: Concurrent Thread-Stack Processing – Moves ZGC thread-stack processing from safepoints to a concurrent phase. This work eliminates the last significant bottleneck for allowing concurrent stack processing.

Improved Networking to Improve Developer Productivity and Flexibility

  • JEP 380: UNIX-Domain Socket Channels – Adds support for all of the features of UNIX-domain sockets that are common across the major UNIX platforms and Windows to the socket channel and server-socket channel APIs in the java.nio.channels package. UNIX-domain sockets are used for inter-process communication (IPC) on the same host. They are similar to TCP/IP sockets in most respects, except they are addressed by filesystem path names rather than Internet Protocol (IP) addresses and port numbers.

Addressing Future-incompatible Code

  • JEP 396: Strongly Encapsulate JDK Internals by Default – In JDK 9 we strongly encapsulated new internal API elements, thereby limiting access to them. As an aid to migration, however, JDK 9 deliberately chose not to strongly encapsulate at run time the content of packages that existed in JDK 8. JDK 16 tightens this constraint by encapsulating most internal elements of the JDK by default, except for critical internal APIs such as sun.misc.Unsafe. End users can still choose the relaxed strong encapsulation that has been the default since JDK 9. This will encourage developers to migrate from using internal elements to using standard APIs, so that both they and their users can upgrade without fuss to future Java releases.
  • JEP 390: Warnings for Value-Based Classes – Designates the primitive wrapper classes as value-based and deprecate their constructors for removal, prompting new deprecation warnings. Provides warnings about improper attempts to synchronize on instances of any value-based classes in the Java Platform.

Incubating and Preview Features

  • JEP 338: Vector API (Incubator) – Provides an initial iteration of an incubator module, jdk.incubator.vector, to express vector computations that reliably compile at runtime to optimal vector hardware instructions on supported CPU architectures.
  • JEP 389: Foreign Linker API (Incubator) – Introduces an API that offers statically-typed, pure-Java access to native code.
  • JEP 393: Foreign-Memory Access API (Third Incubator) – Introduces an API to allow Java programs to safely and efficiently access foreign memory outside of the Java heap.
  • JEP 397: Sealed Classes (Second Preview) – Enhances the Java programming language with sealed classes and interfaces. Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.

Improvements for OpenJDK Contributors

New Ports Provide Support for Java on More Platforms

  • JEP 386: Alpine Linux Port – Ports the JDK to Alpine Linux, and to other Linux distributions that use musl as their primary C library, on both the x64 and AArch64 architectures.
  • JEP 388: Windows/Aarch64 Port – Ports the JDK to Windows/AArch64.

Oracle delivers Java updates every six months.

[Image courtesy: Oracle]