After the first release candidate last month, Java 11 is now generally available. The GA version is the first release with long-term support (LTS). Some of the new features include nest-based access control, a new garbage collector, support for Unicode 11 and TLS 1.3.
New features in Java 11
Some of the new features in Java 11 include nest-based access control, dynamic class-file constants, a no-op garbage collector called Epsilon and more. Let’s look at these features in detail.
Nest-based access control
‘Nests’ are introduced as an access control context that aligns with the existing nested types in Java. Classes that are logically part of the same code but are compiled to distinct files can access private members with nests. It eliminates the need for compilers to insert bridge methods. Two members in a nest are described as ‘nestmates’. Nests do not apply to large scales of access control like modules.
Dynamic class-file constants
The existing Java class-file format is extended to support a new constant-pool form called CONSTANT_Dynamic. Loading this new form will delegate its creation to a bootstrap method in the same way linking an invokedynamic call site delegates linkage to a bootstrap method. The aim is to reduce the cost and disruption of creating new forms of materializable class-file constants giving broader options to language designers and compiler implementors.
Epsilon, a no-op garbage collector
Epsilon is a new experimental garbage collector in Java 11 that handles memory allocation but does not actually reclaim any memory. It works by implementing linear allocation in a single contiguous chunk memory. The JVM will shut down when the available Java heap is exhausted.
Added support for Unicode 11
Java 11 brings Unicode 11 support to existing platform APIs. The following Java classes are mainly supported with Unicode 10:
- In the java.lang package: Character and String
- In the java.awt.font package: NumericShaper
- In the java.text package: Bidi, BreakIterator, and Normalizer
This upgrade includes Unicode 9 changes and adds a total of 16,018 characters and ten new scripts.
The flight recorder in Java 11 is a data collection framework for troubleshooting Java applications and the HotSpot JVM. It has a low overhead.
TLS 1.3 was recently standardized and is the latest version of the Transport Layer Security protocol. TLS 1.3 is not directly compatible with the previous versions. The goal here is not to support every feature of TLS 1.3.
For a complete list of features and deprecations, visit the JDK website.