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

Monday, March 6, 2023

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

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

New Features and Enhancements

- specification/language: Sealed Classes (Preview). A sealed class or interface can be extended or implemented only by those classes and interfaces permitted to do so.
public abstract sealed class Shape permits Circle, Rectangle, Square {...}

- specification/language: Pattern Matching for instanceof (Second Preview). No changes from JDK 14

- specification/language: Records (Second Preview). Family of records can implement the same sealed interface.
Local records, declared within a method, like:
doSomething() {
record SomeRecord(String param1, String param2) {}
}
Annotations on records:
record SomeRecord(@SomeAnnot String param1, @SomeAnnot String param2) {}

- core-libs/java.lang: Added isEmpty Default Method to CharSequence, which returns the result of calling length() == 0
- core-libs/java.lang: Support for Unicode 13.0

- core-libs/java.lang.invoke: JEP 371 Hidden Classes
Introduce hidden classes, which are classes that cannot be used directly by the bytecode of other classes.
Hidden classes are intended for use by frameworks that generate classes at run time and use them indirectly, via reflection.
A hidden class may be defined as a member of an access control nest, and may be unloaded independently of other classes.
Compared to anonymouse classes which have a dynamically generated name with $, hidden classes have a /.
Hidden classes are to be used in lambda expressions.
More: JEP 371

- core-libs/java.util:collections: Specialized Implementations of TreeMap Methods
The TreeMap class now provides overriding implementations of the putIfAbsent, computeIfAbsent, computeIfPresent, compute, and merge methods.
The new implementations provide a performance improvement

- tools/javac: JEP 378 Text Blocks became final. See JEP 378 Text Blocks
- hotspot/svc-agent: New Options Added to jhsdb for debugd Modeinstall/install: Oracle JDK Installer for Windows Provides Executables (javac, etc) in a Path Reachable From Any Command Prompt
- security-libs/java.security: Tools Warn If Weak Algorithms Are Used

- security-libs/javax.crypto: Edwards-Curve Digital Signature Algorithm (EdDSA)
- core-libs/java.net: Added Support for SO_INCOMING_NAPI_ID Support
- core-svc/javax.management: Added Ability to Configure Third Port for Remote JMX
- core-svc/tools: New Option Added to jstatd for Specifying RMI Connector Port Number
- core-svc/tools: New Option Added to jcmd for Writing a gzipped Heap Dump
- security-libs/java.security: Added Revocation Checking to jarsigner
- security-libs/javax.crypto: SunJCE Provider Supports SHA-3 Based Hmac Algorithms
- security-libs/javax.net.ssl: New System Properties to Configure the TLS Signature Schemes
- security-libs/javax.net.ssl: Support for certificate_authorities Extension
- security-libs/org.ietf.jgss:krb5: Support for canonicalize in krb5.conf
- security-libs/org.ietf.jgss:krb5: Support cross-realm MSSFU


Removed Features and Options


- core-libs/jdk.nashorn: Removal of Nashorn JavaScript Engine. GraalVM can step in as a replacement for JavaScript code previously executed on the Nashorn engine

- core-libs/java.net: Removal of Terminally Deprecated Solaris-specific SO_FLOW_SLA Socket Option
- core-libs/java.rmi: Removal of RMI Static Stub Compiler (rmic)
- core-svc/javax.management: Removal of Deprecated Constant RMIConnectorServer.CREDENTIAL_TYPES
- hotspot/gc: Obsolete -XXUseAdaptiveGCBoundary
- security-libs/java.security: Removal of Comodo Root CA Certificate
- security-libs/javax.net.ssl: Retired the Deprecated SSLSession.getPeerCertificateChain() Method Implementation
- security-libs/javax.net.ssl: Removal of com.sun.net.ssl.internal.ssl.Provider Name


- ZGC and Shenandoah are production ready. G1 garbage collector is default.

Deprecated Features and Options, Other Notes and Differences between Oracle JDK and OpenJDK not included