Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

JDK15 is officially released with a preview of what's new!


May 31, 2021 Article blog


Table of contents


This article comes from the public number: Java Chinese Community Author: Lei ge

JDK 15 was officially released on September 15, 2020, and the main features of this release are:

  • JEP 339:EdDSA Digital Signature Algorithm
  • JEP 360: Seal class (preview)
  • JEP 371: Hide classes
  • JEP 372: Remove the Nashorn JavaScript engine
  • JEP 373: Re-implement the Legacy DatagramSocket API
  • JEP 374: Re-implement the DatagramSocket API
  • JEP 375: Instance Pattern Matching (Second Preview)
  • JEP 377:ZGC: A scalable, low-latency garbage collector
  • JEP 378: Block of text
  • JEP 379: Low pause time garbage collector
  • JEP 381: Remove solaris and SPARC ports
  • JEP 383: External Memory Access API (second built-in program)
  • JEP 384: Records (second preview)
  • JEP 385: RMI activation removal is not recommended

JEP:JDK Proposals, JDK Enhancement Recommendations, i.e. JDK feature additions and improvement proposals.

The number of JEPs corresponding to the releases released over the years is shown in the following image:

 JDK15 is officially released with a preview of what's new!1

Release description

According to the release plan, this release of JDK 15 will be a short-term over-release and will only be supported (maintained) by Oracle for 6 months until this release of JDK 16 in March next year will stop maintenance. Oracle's next long-term support release (LTS) will be released in September next year (Java 17), LTS will be released every 3 years, and the last long-term support release will be JDK 11 released in September 18.

Description of the new features of JDK 15

JDK 15 provides users with fourteen major enhancements/changes, including an incubator module, three preview features, two features that are not recommended, and two removal features.

1, EdDSA digital signature algorithm

Newly added Edwards-Curve Digital Signature Algorithm (EdDSA) enables encrypted signatures. S upport is available in many other encryption libraries, such as OpenSSL and BoringSSL. E dDSA offers greater security and performance than existing signature scenarios in the JDK. This is a new feature.

2, hidden classes

This feature helps frameworks that need to build classes at runtime. F ramework generation classes need to dynamically extend their behavior, but they also want to restrict access to those classes. H idden classes are useful because they can only be accessed by reflection, not by normal bytecode. I n addition, hidden classes can be loaded independently of other classes, which reduces the memory footprint of the framework. This is a new feature.

3, re-implement the DatagramSocket API

Re-implementing legacy DatagramSocket APIs, with simpler, more modern implementations to replace the basic implementations of java.net.DatagramSocket and java.net.MulticastSocket APIs, improves the maintainability and stability of the JDK.

4, ZGC function turn positive

ZGC has been integrated from JEP 333 into JDK 11 with the goal of improving performance by reducing GC pause time. With JEP 377, ZGC moved from preview to production.

5, the text block function turned positive

Proposed by JEP 355 in 2019, a block of text is a multi-line string text that avoids the need for most escape sequences, automatically formats strings in a predictable way, and gives developers control over formats when needed. With JEP 378, text blocks have become a permanent feature of the Java language.

6, Shenandoah garbage collection algorithm turned positive

Shenandoah garbage collection has changed from experimental to product. T his is a recycling algorithm introduced from JDK 12 that reduces GC pause time by simultaneously evacuating with a running Java thread. Shenandoah's pause time is independent of the heap size, and has the same consistent pause time regardless of whether the stack is 200 MB or 200 GB.

7, seal class (preview)

Enhance the Java programming language by sealing classes and interfaces to limit the use of superclasses, and sealed classes and interfaces to restrict other classes or interfaces that might inherit or implement them.

8, instanceof auto-match mode (preview)

Old writing:

// 先判断类型
if (obj instanceof String) {
    // 然后转换
    String s = (String) obj;
    // 然后才能使用
}

New writing:

if (obj instanceof String s) {
    // 如果类型匹配 直接使用
} else {
    // 如果类型不匹配则不能直接使用
}

This is the second time we've previewed the feature, and we've previewed it for the first time in Java 14.

9, Records Class (preview)

Records Class is also a second preview feature, which also appears once in JDK 14, and uses Record to make it easier to create a constant class using the following before and after code comparisons.

Old writing:

class Point {
    private final int x;
    private final int y;


    Point(int x, int y) { 
        this.x = x;
        this.y = y;
    }


    int x() { return x; }
    int y() { return y; }


    public boolean equals(Object o) { 
        if (!(o instanceof Point)) return false;
        Point other = (Point) o;
        return other.x == x && other.y = y;
    }


    public int hashCode() {
        return Objects.hash(x, y);
    }


    public String toString() { 
        return String.format("Point[x=%d, y=%d]", x, y);
    }
}

New writing:

record Point(int x, int y) { }

That is, after using record, you can write a constant class with a row of code, and this constant class also contains methods such as construction methods, toString(), equals(), and hashCode().

10, external memory access API (preview)

The goal is to introduce an API to allow Java programs to securely and efficiently access external memory outside the Java heap. This is also a preview feature of Java 14.

11, other functions

Other features include deprecated and uns recommended features, such as removing the Nashorn JavaScript engine, removing solaris and SPARC ports, and marking some deprecation features.

Above is W3Cschool编程狮 about the official release of JDK15, new features preview! Related to the introduction, I hope to help you.