What’s new in Java 16?

Alona Tomina
3 min readApr 9, 2021

--

What’s new in Java 16?

Oracle has announced the availability of Java 16, aka Oracle Java Development Kit (JDK) 16, on 16 March 2021. Open source builds of JDK 16 for Linux, Windows, and MacOS can be found at jdk.java.net.

Let’s take a closer look at JDK 16. Is it really worth the entire buzz?

Language enhancements

Pattern matching allows common logic in a program, namely the conditional extraction of components from objects, to be expressed more concisely and safely.

Records classes act as transparent carriers for immutable data. Records can be thought of as nominal tuples.

New tool to improve developer productivity

The jpackage tool is used to package self-contained Java applications.

Improved memory management

It returns unused HotSpot class-metadata (metaspace) memory to the operating system promptly, reduces metaspace footprint, and simplifies the metaspace code to reduce maintenance costs.

Moves ZGC thread-stack processing from safepoints to a concurrent phase.

Improved networking

Adds support for all of the features of UNIX-domain sockets to the socket channel and server-socket channel APIs in the java.nio.channels package.

Addressing future-incompatible code

JDK 16 encapsulates most internal elements of the JDK by default, except for critical internal APIs such as sun.misc. End users can choose the relaxed strong encapsulation that has been the default since JDK 9.

Designates the primitive wrapper classes as value-based and deprecates their constructors for removal, prompting new deprecation warnings. Warnings are provided about improper attempts to synchronize on instances of any value-based classes in the Java Platform.

Incubating and preview features

A key innovation for Java 16 is the Vector API. Oracle provides an incubator module, jdk.incubator.vector, to express vector computations that reliably compile at runtime to optimal vector hardware instructions on supported CPU architectures.

This API offers statically-typed, pure-Java access to native code. It will considerably simplify the otherwise error-prone process of binding to a native library.

A foreign-memory access API allows Java programs to safely access foreign memory outside of the Java heap.

Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.

Improvements for OpenJDK contributors

Allows the use of C++14 language features in JDK C++ source code, and gives specific guidance about which of those features may be used in HotSpot code.

Migrates the OpenJDK Community’s source code repositories from Mercurial (hg) to Git.

Hosts the OpenJDK Community’s Git repositories on GitHub.

New ports provide support for Java on more platforms

Port of the JDK to Alpine Linux and other Linux distributions that use musl as their primary C library, on both the x64 and AArch64 architectures.

Ports the JDK to Windows/AArch64.

If you have an awesome idea, we may be the perfect team to help you bring it to life!

--

--