Sunday, February 12, 2023

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

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

New Features and Enhancements

- added support for Unicode 11
- core-libs/java.text: Support for Compact Number Formatting(example: 1000 as 1K). CompactNumberFormat class. NumberFormat class has 2 additional methods related to compact (getCompactNumberInstance)
- TypeDescriptor interface added, though for me wasn't clear the use case. Might be related to some class file internals.
- hotspot/gc: ZGC Concurrent Class Unloading, for lowering the overall footprint of the application
- tools/javac: JEP 325 Switch Expressions (Preview, must be enabled) As statement or expression. Precursor to pattern matching.
Example(taken from JEP) from:

switch(day){
    case MONDAY:
    case FRIDAY:
    case SUNDAY:
        System.out.println(6);
        break;
    case WEDNESDAY:
        System.out.println(9);
        break;
}

to:

switch (day) {
    case MONDAY, FRIDAY, SUNDAY -> System.out.println(6);
    case WEDNESDAY              -> System.out.println(9);
}

Switch expression:

int numLetters = switch (day) {
    case MONDAY, FRIDAY, SUNDAY -> 6;
    case WEDNESDAY              -> 9;
};
- core-libs/java.lang.invoke: JEP 334 JVM Constants API: Constable, ClassDesc, ConstantDesc etc. within java.base
Most JDK classes have changes related to constable.
- 2 new methods in String class: indent and transform
- File.mismatch(java.nio.file.Path,java.nio.file.Path). Finds and returns the position of the first mismatched byte in the content of two files, or -1L if there is no mismatch
- CompletableFuture, added new methods: exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync
- Collectors.teeing​ -> Returns a Collector that is a composite of two downstream collectors


- core-libs/java.lang: POSIX_SPAWN Option on Linux
- core-libs/java.util:i18n: Square Character Support for Japanese New Era
- hotspot/gc: Allocation of Old Generation of Java Heap on Alternate Memory Devices
- hotspot/runtime: HotSpot Windows OS Detection Correctly Identifies Windows Server 2019 (Prior to that it was detected as 2016)
- hotspot/runtime: Command-Line Flag -XX+ExtensiveErrorReports (more extensive reporting + sensitive)
- security-libs/java.security: disallow and allow Options for java.security.manager System Property
- security-libs/java.security: -groupname Option Added to keytool Key Pair Generation
- security-libs/java.security: New Java Flight Recorder (JFR) Security Events
- security-libs/java.security: Customizing PKCS12 keystore Generation
- security-libs/javax.net.ssl: ChaCha20 and Poly1305 TLS Cipher Suites
- security-libs/org.ietf.jgss:krb5: Support for dns_canonicalize_hostname in krb5.conf
- tools: jdeps --print-module-deps Reports Transitive Dependences


Removed Features and Options

- client-libs/java.awt: Removal of com.sun.awt.SecurityWarning Class
- core-libs/java.io: Removal of finalize Methods from FileInputStream and FileOutputStream.
The java.lang.ref.Cleaner has been implemented since JDK 9 as the primary mechanism to close file descriptors that are no longer reachable from FileInputStream and FileOutputStream. The recommended approach to close files is to explicitly call close or to use try-with-resources.
- core-libs/java.util.jar: Removal of finalize Method in java.util.ZipFile/Inflator/Deflator
- infrastructure/build: Dropped the YY.M Vendor Version String from Oracle-Produced Builds

java 11 2018-09-25
Java(TM) SE Runtime Environment 18.9 (build 11+28)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)

compared to the new one:

java 12 2019-03-19
Java(TM) SE Runtime Environment (build 12+17)
Java HotSpot(TM) 64-Bit Server VM (build 12+17, mixed mode)

- security-libs/java.security: Removal of GTE CyberTrust Global Root
- tools/javac: Removal of javac Support for 6/1.6 source, target, and release Values

Deprecated Features and Options, Other Notes and Differences between Oracle JDK and OpenJDK not included, except:
- hotspot/gc: G1 May Uncommit Memory During Marking Cycle - returning heap to OS
- security-libs/javax.net.ssl: Distrust TLS Server Certificates Anchored by Symantec Root CAs

Wednesday, January 25, 2023

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

Link to the Oracle release notes: Oracle Release Notes
Java SE 11 Final Release Specification

Java API Diff page useful for identification of additions, removals or modifications to the Java API, like adding new methods to String class (isBlank, lines, strip, stripLeading, stripTrailing, repeat)

New Features and Enhancements


- added support for Unicode 9 and 10
- java.net.http: standardized the HttpClient that implements HTTP/2 and WebSocket and which replaces HttpURLConnection API.
- java.util.collections: A new default method toArray(IntFunction) has been added to the java.util.Collection interface.
- java.util:i18n: Updated Locale Data to Unicode CLDR v33
- compiler: Lazy Allocation of Compiler Threads, to prevent initial large amount of compiler threads on multi-cpu machines. -XX:+UseDynamicNumberOfCompilerThreads
- hotspot/gc: The experimental Z concurrent garbage collector:
    1. Pause times do not exceed 10 ms.
    2. Pause times do not increase with the heap or live-set size.
    3. Handle heaps ranging from a few hundred megabytes to multi terabytes in size
For the limitations of this GC, refer to the Release Notes.
- hotspot/gc: Epsilon No-Op Garbage Collector: only allocation, no reclamation. Useful for performance testing.
- security-libs/javax.net.ssl: JEP 332 Transport Layer Security (TLS) 1.3 RFC 8446
- tools/javac: JEP 323: Local-Variable Syntax for Lambda Parameters -> usage of var in declaring the formal parameters of lambda expression.
Imposes restriction on using var for all other formal parameters of a lambda expression.
- tools/launcher: JEP 330 Launch Single-File Source-Code Programs -> Java launcher to run a program supplied as a single file of Java source code.

- hotspot/jvmti: Provide a low-overhead way of sampling Java heap allocations, accessible via JVMTI:
    1. low overhead
    2. sampling all allocations
    3. can be GC algorithm or VM implementation agnostic.
    4. info about live and dead Java objects.
- hotspot/runtime: Nest-Based Access Control -> arrangement of classes and interfaces in nests. Low level change.
Allows classes and interfaces which are logically related to same code, but compiled to distinct class files to access private members without bridge methods.
- security-libs: JEP 324 Key Agreement with Curve25519 and Curve448
- security-libs/javax.crypto: Added Brainpool EC Support (RFC 5639)
- security-libs/javax.crypto: JEP 329 ChaCha20 and Poly1305 Cryptographic Algorithms
- security-libs/javax.crypto: Enhanced KeyStore Mechanisms
- security-libs/javax.crypto: RSASSA-PSS Signature Support Added to SunMSCAPI
- security-libs/org.ietf.jgss:krb5: Support for AES Encryption with HMAC-SHA2 for Kerberos 5 Defined in RFC 8009


Removed Features and Options


- client-libs: Removal of com.sun.awt.AWTUtilities Class, deprecated in JDK 10
- client-libs/2d: Removal of Lucida Fonts from Oracle JDK. JDK does not provide anymore any fonts and relies only on OS fonts. Apps will fail.
- client-libs/java.awt: Removal of appletviewer Launcher deprecated in JDK 9
- client-libs/javax.imageio: Oracle JDK's javax.imageio JPEG Plugin No Longer Supports Images with alpha. Apps will fail.
- core-libs/java.lang: Removal of Thread.destroy() and Thread.stop(Throwable) methods. Thread.destroy was never implemented, and stop has been non-functional since Java SE 8.
- core-svc/javax.management: Removal of JVM-MANAGEMENT-MIB.mib -> Now instead of the specification for JVM monitoring and management through SNMP. Customers can use JMX to monitor and manage a running JVM and to access the standard set of metrics and operations.
- deploy: Removal of Java Deployment Technologies -> The Java Plugin and Java WebStart technologies that were deprecated in JDK 9 and marked as candidates for removal in JDK 10, have now been removed
- infrastructure: Removal of Java Mission Control from the Oracle JDK, available separately.
- javafx/other: Removal of JavaFX from the Oracle JDK, available separately, as OpenJFX

- core-libs: Removal of sun.misc.Unsafe.defineClass. Now must use: java.lang.invoke.MethodHandles.Lookup.defineClass
- core-libs/java.nio: Removal of sun.nio.ch.disableSystemWideOverlappingFileLockCheck Property, introduced in JDK for supressing JVM-wide file locking.
- core-libs/java.util:i18n: Removal of sun.locale.formatasdefault Property introduced in JDK7.
- core-svc/tools: Removal of SNMP Agent jdk.snmp.
- other-libs: JEP 320 Remove the Java EE and CORBA Modules:
    1. java.xml.ws
    2. java.xml.bind
    3. java.activation
    4. java.xml.ws.annotation
    5. java.corba
    6. java.transaction
    7. java.se.ee
    8. jdk.xml.ws
    9. jdk.xml.bind
    + other changes.


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