Sunday, October 8, 2023

What's new in JDK 16(my short version)

Oracle Release Notes
Java SE 16 Final Release Specification
Java API Diff page: +,-,change

New Features and Enhancements

- core-libs: Foreign Linker API (Incubator)API that offers statically-typed, pure-Java access to native code for simplification of native library binding

- core-libs: Strongly Encapsulate JDK Internals by Default . Strongly encapsulate all internal elements of the JDK by default, except for critical internal APIs such as sun.misc.Unsafe. Existing code that uses most internal classes, methods, or fields of the JDK will fail to run

- core-libs: Foreign-Memory Access API (Third Incubator). Introduce an API to allow Java programs to safely and efficiently access foreign memory outside of the Java heap

- core-libs/java.lang:reflec: Add InvocationHandler::invokeDefault Method for Proxy's Default Method Support

- core-libs/java.time: Day Period Support Added to java.time Formats. A new formatter pattern, letter 'B', so applications can now express periods in a day, such as "in the morning" or "at night", not just am/pm.

- core-libs/java.util.stream: Add Stream.toList() Method

- hotspot/gc: ZGC Concurrent Stack Processing. Concurrent threads stacks processing in concurrent phase instead of the stop-the-world pauses. Amount of work in ZGC pauses now constant not exceeding few hundred microseconds.

- hotspot/gc: Concurrently Uncommit Memory in G1. Changes the time when G1 returns Java heap memory to OS. Sizing decisions still made during GC pause, but expensive work offloaded to a concurrent thread.

- tools/javac: Sealed Classes (Second Preview)Inheriting classes of a sealed class have to be marked with one of the following keywords: sealed, final, non-sealed
In future release, type test patterns will improve the code:

Shape rotate(Shape shape, double angle) {
    if (shape instanceof Circle) return shape;
    else if (shape instanceof Rectangle) return shape.rotate(angle);
    else if (shape instanceof Square) return shape.rotate(angle);
    // no else needed!
}
transforms into:
Shape rotate(Shape shape, double angle) {
    return switch (shape) { // pattern matching switch
        case Circle c    -> c;
        case Rectangle r -> r.rotate(angle);
        case Square s    -> s.rotate(angle);
        // no default needed!
    }
}

The Java Virtual Machine recognizes sealed classes and interfaces at runtime, and prevents extension by unauthorized subclasses and subinterfaces.

- tools/javac: Records added as fully functional component of Java language. They act as transparent carriers for immutable data with less ceremony than normal classes. Records now can be used as class members of inner classes

- tools/javac: Pattern Matching for instanceof made final

- tools/jpackage: Packaging Tool jpackage tool, for packaging self-contained Java applications, incubating from java 14


- core-libs: Warnings for Value-based Classes, for discouraging calling the wrapper class constructors and synchronization on value-based class instances
- core-libs/java.nio: Unix domain sockets
- hotspot/compiler: Vector API (Incubator). Vector computations at runtime to optimal vector hardware instructions on supported CPU architectures for superior performance
- hotspot/compiler: Improved CompileCommand Flag
- hotspot/jfr: New jdk.ObjectAllocationSample Event Enabled by Default
- hotspot/runtime: "Elastic Metaspace"."Elastic Metaspace" overhauls the VM-internal metaspace- and class-space-implementation. Less memory is used for class metadata. The savings effect is mostly noticeable in scenarios involving lots of small grained class loaders. Upon class unloading, memory is timely returned to the operating system
- security-libs/java.security: Signed JAR Support for RSASSA-PSS and EdDSA. The JarSigner API and the jarsigner tool now support signing a JAR file with an RSASSA-PSS or EdDSA key
- security-libs/java.security: SUN, SunRsaSign, and SunEC Providers Supports SHA-3 Based Signature Algorithms
- security-libs/java.security: jarsigner Preserves POSIX File Permission and symlink Attributes
- security-libs/java.security: Added -trustcacerts and -keystore Options to keytool -printcert and -printcrl Commands
- security-libs/javax.crypto: SunPKCS11 Provider Supports SHA-3 Related Algorithms
- security-libs/javax.net.ssl: Improve Certificate Chain Handling
- security-libs/javax.net.ssl: Improve Encoding of TLS Application-Layer Protocol Negotiation (ALPN) Values
- security-libs/javax.net.ssl: TLS Support for the EdDSA Signature Algorithm


Removed Features and Options


- security-libs/java.security: Removed Root Certificates with 1024-bit Keys
- security-libs/javax.crypto: Removal of Legacy Elliptic Curves

- client-libs/java.awt: Removal of java.awt.PeerFixer
- hotspot/compiler: Removal of Experimental Features AOT and Graal JIT
- hotspot/runtime: Deprecated Tracing Flags Are Obsolete and Must Be Replaced With Unified Logging Equivalents


Deprecated Features and Options, other notes and differences between Oracle JDK and OpenJDK not included

No comments:

Post a Comment

Please comment strictly on the post and its contents. All comments that do not follow this guideline or use this blog as advertising platform, which made me enable moderation, will not be accepted.