JDK 15 was released on September 15, 2020, with the following features:

  • JEP 339: EdDSA digital signature algorithm
  • JEP 360: Sealing Class (Preview)
  • JEP 371: Hidden class
  • JEP 372: Remove 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: An extensible low-latency garbage collector
  • JEP 378: Text block
  • JEP 379: Low pause time garbage collector
  • JEP 381: Remove the Solaris and SPARC ports
  • JEP 383: External Memory Access API (second built-in program)
  • JEP 384: Records (Second Preview)
  • JEP 385: Not recommended for RMI activation removal

JEP: JDK Enhancement Proposals.

The number of JEPs released in these years is shown below:

Release Notes

According to the release plan, JDK 15 will be a short-term interim release that will only be supported by Oracle for six months until JDK 16 is released in March. Oracle’s next long term support (LTS) release will be in September of next year (Java 17). LTS releases come every three years. The last long term support release was JDK 11 in September of 2018.

New features in JDK 15

JDK 15 provides users with fourteen major enhancements/changes, including an incubator module, three preview features, two deprecated features, and two delete features.

1. EdDSA digital signature algorithm

The edWARDs-Curve digital signature algorithm (EdDSA) is added to implement encrypted signature. It is supported in many other cryptographic libraries, such as OpenSSL and BoringSSL. EdDSA offers higher security and performance than existing signature schemes in the JDK. This is a new feature.

2. Hide classes

This feature helps frameworks that need to generate classes at run time. The framework generates classes that need to dynamically extend their behavior, but want to restrict access to those classes. Hidden classes are useful because they can only be accessed through reflection, not from ordinary bytecode. In 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 DatagramSocket API

To realize the old DatagramSocket API, simpler, more modern implementation instead of java.net.DatagramSocket and java.net.MulticastSocketAPI implementation, improve the maintainability and stability of the JDK.

4. ZGC functions are turned positive

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

5, text block function to normal

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

Shenandoah garbage collection algorithm turned positive

Shenandoah garbage collection changed from experimental to production. This is a reclaim algorithm imported from JDK 12 that reduces GC pause times by evacuating at the same time as running Java threads. Shenandoah’s pause time is independent of the heap size and has the same consistent pause time whether the stack is 200 MB or 200 GB.

7. Sealed (preview)

Enhancement of the Java programming language with sealed classes and interfaces that limit the use of superclasses from other classes or interfaces that may inherit or implement them.

8. Instanceof Automatic Matching Mode (preview)

Old writing:

// Determine the type first
if (obj instanceof String) {
    // Then convert
    String s = (String) obj;
    // Then you can use it
}
Copy the code

A new method:

if (obj instanceof String s) {
    // Use it directly if the type matches
} else {
    // If the type does not match, it cannot be used directly
}
Copy the code

This is the second preview of the feature, having already previewed it for the first time in Java 14.

9. Records Class (Preview)

The Records Class is also a second preview feature, which was introduced in JDK 14. Using Record makes it easier to create a constant Class.

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(a) { return x; }
    int y(a) { return y; }

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

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

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

A new method:

record Point(int x, int y) {}Copy the code

That is, after using Record, you can write a one-line constant class that also contains constructors, toString(), equals(), and hashCode().

10. External Memory Access API (Preview)

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

11. Other functions

Other features include deprecated and not recommended features such as removing the Nashorn JavaScript engine, removing Solaris and SPARC ports, and marking deprecated features.

Reference & acknowledgements

Code farmers little elder brother: mp.weixin.qq.com/s/rhfSLW0wf…

The official log: openjdk.java.net/projects/jd…

Follow the public account “Java Chinese community” to send “interview”, I organized the latest interview review materials.