Oracle announces the availability of Java 16: Overview of the new features and improvements of the JDK
Oracle announces the availability of Java 16 with 17 new features (JEP) to improve developer productivity. The latest version of the Java Development Kit (JDK) includes record finalization and pattern matching for the instanceof operator, as well as language enhancements previewed in Java 14. Developers will also be able to use the new packaging tool to deliver self-contained Java applications, as well as learn about three incubating programming interfaces: the Vector API, the Foreign Link Editing API and the Foreign Memory Access API. In addition, there is a feature that is available in pre-release: sealed classes.
Oracle releases updates to Java every six months so that developers can rely on a predictable release schedule. Innovations are released at a steady pace to constantly improve performance, stability and security, and to help spread Java to companies in all industries, regardless of size.
So, after a six-month period of intense collaboration between Oracle engineers and members of the Java community, JDK 16 is now available with its share of new features: 17 proposed enhancements (JEPs) related to the language, tools, memory management, with new features in incubation or pre-release status have been integrated.
Language improvements introduced in JDK 14 and finalized in JDK 16
- JEP 394: Pattern Matching for the instanceof operator.
- JEP 395: Records[/B], which can be seen as nominal tuples.
A new tool to improve developer productivity
- JEP 392: a packaging tool, jpackage, to package self-contained Java applications.
Memory management improvements to further increase performance
- JEP 387: elastic meta-space. This allows unused HotSpot class-metadata memory (i.e., metaspace) to be returned to the operating system more quickly, decreases the metaspace footprint, and simplifies the metaspace code to reduce maintenance costs.
- JEP 376: Concurrent processing of the ZGC thread stack. This involved moving the processing of the ZGC thread stack from safepoints to a concurrent phase.
Improved network to increase flexibility and developer productivity
- JEP 380: UNIX domain socket channels. The enhancement adds support for all Unix domain sockets features (common to Windows and larger Unix platforms) to the socket channel and server socket channel APIs in the java.nio.channels package. Unix domain sockets are used for interprocess communications (IPC) on the same host. They are in many ways comparable to TCP/IP sockets, except that they are addressed by file system path names rather than Internet Protocol (IP) addresses and port numbers.
Inconsistent code handling with future developments
- JEP 396: strong encapsulation of JDK internals by default. In JDK 9, Oracle had strongly encapsulated the new internal API elements, in order to limit access to them. However, to facilitate migration, JDK 9 deliberately chose not to strongly encapsulate at runtime the contents of packages that existed in JDK 8. JDK 16 relaxes this constraint by encapsulating most of the internal JDK elements by default, except for critical internal APIs such as sun.misc.Unsafe. End users can still choose the lighter strong encapsulation that was the default behavior since JDK 9. This solution encourages developers to migrate from using internal elements to using the standard APIs, so that they and their users can move to future versions of Java without problems.
- JEP 390: warnings for value-based classes. The proposal here was to designate primitive wrapper classes as value-based and deprecate their constructors to encourage their removal, generating new deprecation warnings. This release generates warnings of inappropriate synchronization attempts on instances of any value-based class in the Java platform.
Code treatment incompatible with future developments
- JEP 396: strong encapsulation of JDK internals by default. In JDK 9, Oracle had strongly encapsulated the new internal API elements, in order to limit access to them. However, to facilitate migration, JDK 9 deliberately chose not to strongly encapsulate at runtime the contents of packages that existed in JDK 8. JDK 16 relaxes this constraint by encapsulating most of the internal JDK elements by default, except for critical internal APIs such as sun.misc.Unsafe. End users can still choose the lighter strong encapsulation that was the default behavior since JDK 9. This solution encourages developers to migrate from using internal elements to using the standard APIs, so that they and their users can move to future versions of Java without problems.
- JEP 390: warnings for value-based classes. The proposal here was to designate primitive wrapper classes as value-based and deprecate their constructors to encourage their removal, generating new deprecation warnings. This release generates warnings of inappropriate synchronization attempts on instances of any value-based class in the Java platform.
Features in incubation or pre-release status
- JEP 338: Vector API. This feature provides an initial iteration of an incubating module, jdk.incubator.vector, to express vector computations that compile reliably at runtime to optimal vector hardware instructions on supported CPU architectures.
- JEP 389: Foreign Linker API. This feature in incubation status introduces an API that provides access to statically typed pure native Java code.
- JEP 393: Foreign-Memory Access API. This feature, also in incubation status, introduces an API that allows Java programs to safely and efficiently access foreign memory outside the Java heap.
- JEP 397: Sealed Classes (pre-release). This new feature enriches the Java programming language with sealed classes and interfaces. Sealed classes and interfaces restrict which other classes or interfaces can extend or implement them.
Improvements for OpenJDK contributors
- JEP 347: Enabling C++14 language features (in the JDK source code). This enhancement aims to enable the use of C++14 language features in the JDK C++ source code, and make specific recommendations on which features can be used in HotSpot code.
- JEP 357: Mercurial to Git migration. This involved migrating the OpenJDK community's source code repositories from Mercurial (hg) to Git.
- JEP 369 : migration to GitHub (hosting of OpenJDK community Git repositories on GitHub).
New ports for Java support on even more platforms
- JEP 386: ported the JDK to Alpine Linux and other Linux distributions using musl as the primary C library, on both x64 and AArch64 architectures.
- JEP 388: porting the JDK to Windows/Aarch64
According to Georges Saab, Oracle's Vice President of Java platform development, this latest release demonstrates the power of this semi-annual rhythm. "Pattern matching and records were first introduced a year ago with JDK 14, and have since incorporated several rounds of community feedback based on their use in operational applications. This process allowed Java developers to experiment with these features before they were finalized, but it also allowed for this critical feedback to be taken into account to result in two rock-solid JDKs that truly meet the needs of the community," he says. Java 16 is available for download for the various supported platforms.
Source: developpez.com
What about you? What do you think of these new features and improvements?