List of New Features in Java 11 (JEPs)


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.



Below is the list of JEPs that were part of Java 11 development.

JEP JEP Link
181 Nest-Based Access Control
309 Dynamic Class-File Constants
315 Improve Aarch64 Intrinsics
318 Epsilon: A No-Op Garbage Collector
320 Remove the Java EE and CORBA Modules
321 HTTP Client (Standard)
323 Local-Variable Syntax for Lambda Parameters
324 Key Agreement with Curve25519 and Curve448
327 Unicode 10
328 Flight Recorder
329 ChaCha20 and Poly1305 Cryptographic Algorithms
330 Launch Single-File Source-Code Programs
331 Low-Overhead Heap Profiling
332 Transport Layer Security (TLS) 1.3
333 ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
335 Deprecate the Nashorn JavaScript Engine
336 Deprecate the Pack200 Tools and API


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.

    Example:

    import java.net.URI;
    import java.net.http.HttpClient;
    import java.net.http.HttpRequest;
    import java.net.http.HttpResponse;
    
    public class HttpClientExampleJava11 {
    
        public static void main(String[] args) throws Exception {
    
            HttpClient client = HttpClient.newHttpClient();
            HttpRequest request = HttpRequest.newBuilder()
                .uri(new URI("https://code2care.org/v2/api/get-users"))
                .GET()
                .build();
            HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
    
            System.out.println(response.body());
    
        }
    
    }
    

Local-Variable Syntax for Lambda Parameters (JEP 323)

    By this JEP, var can be used when declaring the formal parameters of implicitly typed lambda expressions.

    Example:

    import java.util.function.Predicate;
    
    public class LambdaExampleJEP323 {
    
        public static void main(String[] args) {
    
            Predicate isNotEmpty = (var s) -> s != null && !s.isEmpty();
    
            System.out.println(isNotEmpty.test("Code2care!"));
    
        }
    }
    

Unicode 10 (JEP 327)

    Below existing classes were enhanced to support version 10.0 of the Unicode Standard.

    • Character and String in the java.lang package.
    • NumericShaper in the java.awt.font package.
    • Bidi, BreakIterator, and Normalizer in the java.text package.

    Example:

        public static void main(String[] args) {
            char heartSymbol = '\u2764';
            System.out.println("Heart Symbol: " + heartSymbol);
        }

    Heart Symbol: ❤


Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap