The Java JDK 11 was officially released on September 25, 2018. It is a long-term support (LTS) release, meaning it receives updates and bug fixes for an extended period until September 2026.
Let's try and take a look at some of the new features that were introduced in Java JDK 11 in brief.
Nest-Based Access Control (JEP 181)
Enhanced the access control for nested classes.
JEP 181 introduced nests, enabling logically related classes compiled into separate files to access each other's private members without requiring additional accessibility bridge methods to be inserted by the compiler.
Example:
1. class OuterClass {
2. private int x;
3. class InnerClass {
4. void doSomething() {
5. x = 10; //Accessing the private field of the outer class
6. }
7. }
8. }
Dynamic Class-File Constants (JEP 309)
A new constant-pool CONSTANT_Dynamic form was added to the Java class-file format to efficiently load constants in class files.
Example:
public class Constants {
public static final int SUNDAY = 0;
public static final int MONDAY = 1;
}
Improve Aarch64 Intrinsics (JEP 315)
JEP 315 enhanced the performance of Java applications on AArch64 processors by optimizing intrinsics.
Intrinsics allowed the execution of CPU-specific assembly code instead of generic Java code to boost performance.
Improvements were made by implementing intrinsics for java.lang.Math functions like sin, cos, and log, as well as improving existing intrinsics for string and array operations.
Example:
public static void main(String[] args) {
double angle = 45.0;
double result = Math.sin(angle); // Benefitted from optimized intrinsics on AArch64
}
If you have a Java application that uses the Math.sin function frequently. With JEP 315, the implementation of Math.sin was optimized for AArch64 processors - such as Apple Silicon Chip based M1/M2 processors.
Epsilon: A No-Op Garbage Collector (Experimental) (JEP 318)
JEP 318 introduced Epsilon, a unique experimental (No-Op) garbage collector for Java. Unlike traditional garbage collectors, Epsilon doesn't perform memory reclamation; it simply handles memory allocation. When the Java heap is full, the JVM shuts down.
Helpful for:
Performance Testing
Memory Pressure Testing
VM Interface Testing
Short-Lived Jobs
Latency Improvements
Throughput Improvements
We can enable Epsilon by passing the below argument to the Java Virtual Machine (JVM).
-XX:+UseEpsilonGC
Remove the Java EE and CORBA Modules (JEP 320)
As part of JEP 320, the Java EE and CORBA modules are being removed from the Java SE Platform and JDK because they were deprecated in Java SE 9. This simplifies Java SE, reduces maintenance complexity, and encourages developers to use standalone versions of these technologies.
The inclusion of Java EE and CORBA technologies caused maintenance challenges due to differences between Java SE and Java EE versions. Standalone alternatives are readily available, making their inclusion unnecessary.
In Java SE 9, these modules were marked for removal, and in Java SE 11, they will be removed, including source code deletion. Tools related to these modules will no longer be available. Tests related to Java EE and CORBA APIs will be removed.
HTTP Client (JEP 321)
The HTTP Client API which was introduced in Java 9, was added as a standard feature in Java JDK 11 by JEP-321.
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!