Sunday, November 19, 2023

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

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

New Features and Enhancements

- core-libs/java.nio.charsets: UTF-8 by DefaultUTF-8 is the default charset for the Java SE APIs. Prior to that was the one of the system, local and configuration. file.encoding may accept UTF-8 or COMPAT, latter instructing runtime to behave as previous releases.

- core-libs/java.net: Simple Web Server. Minimal static web server for prototyping usage, ad-hoc coding and testing.

- core-libs/java.net: Internet-Address Resolution SPI. For InetAddress to be able to use other host name and address resolution resolvers instead of the platform build-in local hosts file and DNS.

- tools/javadoc(tool): Code Snippets in Java API Documentation. @snippet tag for example source code in API documentation. The pre Java 18 version was using {@code ...} that had limitations.

- core-libs: Vector API (Third Incubator). Superior performance to equivalent scalar computations

- core-libs: Foreign Function & Memory API (Second Incubator). Interoperation with code and data outside of the Java runtime. Invoke functions outside JVM and memory not managed by the JVM, thus calling native libraries and process native data without JNI

- specification/language: Pattern Matching for switch (Second Preview)

1.  selector expression typing (an integral primitive type or any reference type)
2.  case null
3.  type pattern (case Integer i -> )
4.  guarded patterns (case String s && s.length() > 0 -> )
5.  parentesized patterns (case Triangle t && (t.calculateArea() > 100) ->)
6.  pattern labels dominance (String s included in CharSequence cs -> case)
7.  pattern label completeness (missing cases for switch, compile error)
8.  scope of the pattern variable (in case and block)
9.  new label forms (case null: case String s:) (case null, String s ->)
10. total type (case Object o ->)

More details:
JEP 406
JEP 420
JEP 427

- hotspot/gc: The Z Garbage Collector now supports string deduplication. Each string object takes at least 24 bytes at minimum, has 2 fields value and hash and duplications are removed by replacing char[] only

- hotspot/gc: The Serial Garbage Collector now supports string deduplication

- hotspot/gc: The Parallel Garbage Collector now supports string deduplication

- tools/javac: Expand checks of javac's serial lint warning. Besides the traditional check of serialVersionUID in Serializable class, it has additional checks now.

- tools/javadoc(tool): Options to Include Script Files in Generated Documentation

- tools/javadoc(tool): @SuppressWarnings for DocLint Messages

- core-libs/java.lang:reflect: Reimplement Core Reflection With Method Handles. Reimplementation of core reflection with method handles.
- tools/javac: Passing Originating Elements From Filer to JavaFileManager
- core-libs/java.nio.charsets: Charset.forName() Taking fallback Default Value
- core-libs/java.util: New System Property to Control the Default Date Comment Written Out by java.util.Properties::store Methods
- core-libs/javax.annotation.processing: printError, printWarning, and printNote methods on Messager
- core-libs/javax.lang.model: Method to Get Outermost Type Element
- core-libs/javax.lang.model: Map from an Element to its JavaFileObject
- core-libs/javax.lang.model: Mapping between SourceVersion and Runtime.Version
- hotspot/compiler: Improve Compilation Replay. Compilation Replay is a JVM feature of debug builds that is mainly used to reproduce crashes in the C1 or C2 JIT compilers.
- hotspot/gc: Configurable Card Table Card Size
- hotspot/gc: Allow G1 Heap Regions up to 512MB
- hotspot/jfr: JDK Flight Recorder Event for Finalization
- security-libs: SunPKCS11 Provider Now Supports Some PKCS#11 v3.0 APIs
- security-libs/java.security: Alternate Subject.getSubject and doAs APIs Created That Do Not Depend on Security Manager APIs
- security-libs/java.security: KeyStore Has a getAttributes Method
- security-libs/java.security: Support for RSASSA-PSS in OCSP Response
- security-libs/java.security: New Option -version Added to keytool and jarsigner Commands
- security-libs/java.security: Migrate cacerts From JKS to Password-Less PKCS12
- security-libs/java.security: Allow Store Password to Be Null When Saving a PKCS12 KeyStore
- security-libs/javax.crypto:pkcs11: SunPKCS11 Provider Supports AES Cipher With KW and KWP Modes if Supported by PKCS11 Library


Removed Features and Options


- security-libs/java.security: Removal of IdenTrust Root Certificate
- security-libs/java.security: Removal of Google's GlobalSign Root Certificate
- client-libs/2d: Removal of Empty finalize() Methods in java.desktop Module
- core-libs/java.net: Removal of Support for Pre JDK 1.4 DatagramSocketImpl Implementations
- core-libs/java.net: Removal of impl.prefix JDK System Property Usage From InetAddress
- core-libs/java.net: Removal of Legacy PlainSocketImpl and PlainDatagramSocketImpl Implementations
- security-libs/org.ietf.jgss:krb5: Removal of default_checksum and safe_checksum_type From krb5.conf

- security-libs/java.security: Removed Telia Company's Sonera Class2 CA Certificate


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

Sunday, October 8, 2023

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

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

New Features and Enhancements

- specification: Finalized sealed classes with no changes from JDK 16

- specification: Pattern Matching for switch (Preview). Enhance the Java programming language with pattern matching for switch expressions and statements, along with extensions to the language of patterns

- core-libs/java.util: Enhanced Pseudo-Random Number Generators. Added RandomGenerator interface now implemented by legacy classes

- hotspot/compiler: Modernization of Ideal Graph Visualizer (a tool to explore visually and interactively the intermediate representation used in the HotSpot VM C2 just-in-time (JIT) compiler)

- tools/javadoc(tool): Source Details in Error Messages. When JavaDoc reports an issue in an input source file, it displays the source line for the issue, and a line containing a caret (^) pointing to the position on the line, in a manner similar to compiler (javac) diagnostic messages.

- tools/javadoc(tool): New Page for "New API" and Improved "Deprecated" Page. JavaDoc can now generate a page summarizing the recent changes in an API.

- core-libs: Foreign Function & Memory API (Incubator). Call code and data outside of Java, without JNI.

- core-libs/java.io:serialization: JDK Flight Recorder Event for Deserialization in order to monitor deserialization events.

- core-libs/java.time: Add java.time.InstantSource. Abstraction from java.time.Clock that only focuses on the current instant and does not refer to the time zone

- core-libs/java.util: Hex Formatting and Parsing Utility.

- hotspot/compiler: New Class Hierarchy Analysis Implementation in the HotSpot JVM. Enhanced handling of abstract and default methods which improves inlining decisions made by the JIT-compilers. The new implementation supersedes the original one and is turned on by default

- security-libs/javax.crypto: SunJCE Provider Supports KW and KWP Modes With AES Cipher.

- tools/javadoc(tool): "Related Packages" on a Package Summary Page.

- core-libs/java.lang: Make floating-point operations consistently strict, rather than have both strict floating-point semantics (strictfp) and subtly different default floating-point semantics. This will restore the original floating-point semantics to the language and VM, matching the semantics before the introduction of strict and default floating-point modes in Java SE 1.2.

- Added new method to Map.Entry: copyOf(java.util.Map.Entry).

- client-libs/2d: New macOS Rendering Pipeline
- client-libs/javax.swing: New API for Accessing Large Icons
- core-libs/java.net: DatagramSocket Can Be Used Directly to Join Multicast Groups
- core-libs/java.nio: Add support for UserDefinedFileAttributeView on macOS
- core-libs: Console Charset API
- core-libs/java.io:serialization: Implement Context-Specific Deserialization Filters
- core-libs/java.lang: System Property for Native Character Encoding Name
- hotspot/compiler: Experimental Compiler Blackholes Support.
- hotspot/compiler: macOS/AArch64 Port.
- hotspot/runtime: Unified Logging Supports Asynchronous Log Flushing.
- infrastructure/build: macOS on ARM Early Access Available.
- security-libs/java.security: Provide Support for Specifying a Signer in Keytool -genkeypair Command.
- security-libs/javax.crypto:pkcs11: New SunPKCS11 configuration properties
- security-libs/javax.crypto:pkcs11: SunPKCS11 Provider Supports ChaCha20-Poly1305 Cipher and ChaCha20 KeyGenerator if Supported by PKCS11 Library
- security-libs/javax.net.ssl: Configurable Extensions With System Properties
- security-libs/org.ietf.jgss:krb5: Use permitted_enctypes if default_tkt_enctypes or default_tgs_enctypes is not present.


Removed Features and Options


- core-libs: Strongly Encapsulate JDK Internals. The java launcher option --illegal-access is obsolete. Existing code that must use internal classes, methods, or fields of the JDK can still be made to work by using the --add-opens launcher option, or the Add-Opens JAR-file manifest attribute, to open specific packages.
- core-libs/java.rmi: JEP 407: Remove RMI Activation.
- hotspot/compiler: JEP 410: Remove the Experimental AOT and JIT Compiler.

- security-libs/java.security: Removed Telia Company's Sonera Class2 CA Certificate
- core-libs: Removal of sun.misc.Unsafe::defineAnonymousClass.


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

- Deprecate the Applet API for Removal (It is essentially irrelevant since all web-browser vendors have either removed support for Java browser plug-ins or announced plans to do so)
- Deprecate the Security Manager for Removal (It has not been the primary means of securing client-side Java code for many years, and it has rarely been used to secure server-side code)

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

Sunday, February 26, 2023

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

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

New Features and Enhancements

- Pattern matching instanceof
Examples(from JEP 305):
if (obj instanceof String s) {
    // can use s here
} else {
    // can't use s here
}

@Override public boolean equals(Object o) {
    return (o instanceof CaseInsensitiveString cis) &&
        cis.s.equalsIgnoreCase(s);
}

- Switch Expressions from JDK12 and JDK13 made Standard.

- Text Blocks, second preview, adding 2 new escape sequences:
    \ - line-terminator
    \s - single space

- core-libs: Accounting Currency Format Support, NumberFormat.getCurrencyInstance(Locale)

- core-libs/java.lang: JEP 359 Records (Preview) - data carrier classes.
Example:
record Point(int x, int y) { }
record (name)(state description -> i.e. components of the record) {}
More info:
    * A private final field for each component of the state description;
    * A public read accessor method for each component of the state description, with the same name and type as the component;
    * A public constructor, whose signature is the same as the state description, which initializes each field from the corresponding argument;
    * Implementations of equals and hashCode that say two records are equal if they are of the same type and contain the same state; and
    * An implementation of toString that includes the string representation of all the record components, with their names.
    * Records are final, non-abstract and cannot extend other class and cannot declare instance fields other than the private final fields of state description.
    * Components are final
    * isRecord method added to Class

- RecordComponent class added, that provides information about, and dynamic access to, a component of a record class
- RecordComponentElement interface added, representing a record component.
- TypeElement getRecordComponents method added.
- hotspot/gc: JEP 365 ZGC on Windows. The Z Garbage Collector (ZGC) is now available as an experimental feature on Windows
- hotspot/gc: JEP 364 ZGC on macOS. The Z Garbage Collector (ZGC) is now available as an experimental feature on macOS.
- hotspot/gc: Parallel GC Improvements. Parallel GC has adopted the same task management mechanism for scheduling parallel tasks as other collectors. This might result in significant performance improvements.
- hotspot/jfr: JEP 349 JFR Event Streaming. JDK Flight Recorder (JFR) now supports continuous monitoring of a Java application by allowing events to be consumed dynamically using a new API located in the jdk.jfr.consumer package.
- StrictMath added decrementExact, incrementExact and negateExact for int and long.
- PrintStream added write(byte[]) and writeBytes(byte[]) methods, equivalent to write(buf, 0, buf.length). One has throws, the other does not.

- Added optional @Serial annotation, for annotating methods or fields, to help compiler.
This annotation will check the following:
Your methods are one of the following:
    * private void writeObject(java.io.ObjectOutputStream stream) throws IOException
    * private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException
    * private void readObjectNoData() throws ObjectStreamException
    * ANY-ACCESS-MODIFIERObject writeReplace() throws ObjectStreamException
    * ANY-ACCESS-MODIFIERObject readResolve() throws ObjectStreamException
Your fields are one of the following:
    * private static final ObjectStreamField[] serialPersistentFields
    * private static final long serialVersionUID

- HashSet added new method: toArray()
- LockSupport added setCurrentBlocker(Object) method.

- xml/jaxp: New Method to SAX ContentHandler for Handling XML Declaration
- tools/javac: Allow Discoverable javac Plugins to be Invoked by Default
- security-libs/javax.xml.crypto: Apache Santuario Library Updated to Version 2.1.4
- security-libs/java.security: Weak Named Curves in TLS, CertPath, and Signed JAR Disabled by Default.
- hotspot/gc: JEP 345 NUMA-Aware Memory Allocation for G1.
- core-libs/java.nio: Clarify the Specification of ReadableByteChannel.read() and Related Methods


Removed Features and Options

- hotspot/gc: JEP 363 Remove the Concurrent Mark and Sweep (CMS) Garbage Collector (JEP 363)
- core-libs/java.nio.charsets: Removal of sun.nio.cs.map System Property
- deploy: Removal of netscape.javascript.JSObjectgetWindow Method
- security-libs/java.security: Removed Deprecated java.security.acl APIs
- security-libs/java.security: Removal of the Default keytool -keyalg Value
- tools/jar: JEP 367 Remove the Pack200 Tools and API

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

Sunday, February 19, 2023

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

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

New Features and Enhancements

- core-libs/java.nio: added FileSystems.newFileSystem method for file system files.
- core-libs/java.nio: java.nio.ByteBuffer and the other buffer types in java.nio now define absolute bulk get and put methods to transfer contiguous sequences of bytes without regard to or effect on the buffer position.
- core-libs/java.time: New Japanese Era Name Reiwa
- core-libs/java.util:i18n: Support for Unicode 12.1
- hotspot/gc: ZGC was enhanced to return unused heap memory to the operating system. Memory will not be uncommitted so that the heap size shrinks below the minimum heap size (-Xms). This means this feature will be implicitly disabled if the minimum heap size (-Xms) is configured to be equal to the maximum heap size (-Xmx)
- hotspot/gc: Added -XXSoftMaxHeapSize Flag, working only on Z garbage collector. This flag is useful when resource usage is a concern to keep heap low but allow to deal with temporary heap increase. An additional case would be when using ZGC to more aggressively collect garbage, for more resilience to a sudden increase in allocation.
- hotspot/gc: The maximum supported heap size for ZGC was increased from 4TB to 16TB.
- hotspot/runtime: Dynamic CDS Archiving - Application class data sharing, used to improve startup and footprint by allowing classes to be placed in the shared archive (Application Class-Data Sharing) is extended to be dynamic on application exit.
- tools/javac: JEP 354 Switch Expressions (Second Preview) - To yield a value from a `switch` expression, the `break` with value statement is dropped in favor of a `yield` statement. See JEP 325: Switch Expressions (Preview) for previous.

Examples:
int j = switch (day) {
    case MONDAY  -> 0;
    case TUESDAY -> 1;
    default      -> {
        int k = day.toString().length();
        int result = f(k);
        yield result;
    }
};

int result = switch (s) {
    case "Foo":
        yield 1;
    case "Bar":
        yield 2;
    default:
        System.out.println("Neither Foo nor Bar, hmmm...");
        yield 0;
};

- tools/javac: JEP 355 Text Blocks (Preview) - A text block is a multi-line string literal that avoids the need for most escape sequences, automatically formats the string in a predictable way, and gives the developer control over format when desired

Example:
String textBlock = """
"somestringWithinDoubleQuotes"
""";

- security-libs/java.security: Configurable Read Timeout for CRLs
- security-libs/java.security: New keytool -showinfo -tls Command for Displaying TLS Configuration Information
- security-libs/javax.crypto: Support for MS Cryptography Next Generation (CNG), thus allowing RSA and EC keys in CNG format to be loaded from Windows keystores.
- security-libs/javax.crypto:pkcs11: SunPKCS11 Provider Upgraded with Support for PKCS#11 v2.40
- security-libs/javax.net.ssl: Support for X25519 and X448 in TLS
- security-libs/javax.net.ssl: Session Resumption without Server-Side State in JSSE
- security-libs/javax.security: Allow SASL Mechanisms to Be Restricted
- security-libs/javax.xml.crypto: New String Constants for Canonical XML 1.1 URIs
- security-libs/javax.xml.crypto: [xmldsig] Added KeyValueEC_TYPE
- security-libs/org.ietf.jgss: Added a Default Native GSS-API Library on Windows
- security-libs/org.ietf.jgss:krb5: Support for Kerberos Cross-Realm Referrals (RFC 6806)
- xml/jaxp: New Methods for Creating DOM and SAX Factories with Namespace Support


Removed Features and Options

- client-libs: Removal of awt.toolkit System Property
- core-libs/java.lang: Removal of Runtime Trace Methods
- core-libs/java.net: Pre-JDK 1.4 SocketImpl Implementations No Longer Supported
- hotspot/runtime: Removal of VM option -XX+AggressiveOpts
- security-libs: Duplicated RSA Services No Longer Supported by SunJSSE Provider
- security-libs/java.security: Removal of T-Systems Deutsche Telekom Root CA 2 Certificate
- security-libs/java.security: Removal of Two DocuSign Root CA Certificates
- security-libs/java.security: Removal of Two Comodo Root CA Certificates
- security-libs/javax.net.ssl: Removal of the Internal com.sun.net.ssl Package Only Used for Compatibility with Legacy JSSE 1.0 Applications
- security-libs/javax.net.ssl: Removal of Experimental FIPS 140 Compliant Mode from SunJSSE Provider
- tools/javadoc(tool): Removal of Old Features from javadoc Tool

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

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.

Sunday, June 19, 2022

On-demand developer oriented continuous integration

Nowadays, expectations from software engineering (or development, depending how you see it) are extremely high:

  1. MVP (Minimum Viable Product) delivered ASAP.
  2. Agility through the whole development process, in order to adapt to ever changing priorities or client desires
  3. Optimized/reduced costs
  4. Early new problem/bug/error detection
  5. Team collaboration
  6. Security
  7. Early regression discovery

    ...and many others.

One of the practices that helps mitigate several problems that arise during the software engineering process is the continuous integration (CI), concept credited to Grady Booch.

In small, short term projects CI is rarely set up because of the associated hardware or plan(in cases of the ones supporting Cloud) costs and the need for a dedicated workforce that would set it up and maintain it, whereas in the case of medium to large projects this is always a good idea and it pays off over time.

The CI which I had to use over the years was almost exclusively dominated by such a tool as Jenkins, with a slight exception that happened last year, when I had to configure an Azure Pipeline for testing purposes, process which, while pretty straightforward, demonstrated some core conceptual differences between the two, important enough so that the clients(including myself) to complain "But this works like that in Jenkins, why can't I do this here?". 

Funny enough, like when you are developing something using some proprietary tools/frameworks, the answer you give to clients is: "This is not currently supported, it is a closed-source software product owned by company X, so we can't do much about this.". The only thing you can do is wait until lots of other clients need this same functionality and the company X starts considering implementing it.

There are different ways to configure and use Jenkins, but I was introduced, in the last 5 years, to the following big categories:

  • Main CI
  • Custom CI

Main CI is usually automatic. It gathers several commits together and builds CI continuously through the day. Custom CI, however, is on-demand, developer oriented. Imagine that you are working on some important task and before you commit to master(or the now trending main), you want to make sure that nothing is broken by what you've done. Custom CI helps you here. You input your branch into the Custom CI UI, and it will build it like if you would have your new changes already integrated to master.

Now, while this sounds pretty cool and helpful, it is important to understand that Custom CI must be treated as a First Class Citizen (FCC). Custom CI must be maintained, evolved and worked upon even more, sometimes, in my opinion, than Main CI.

I will list below several problems that I personally encountered, or missing functionality that I needed but was missing while I was using Custom CI over the years, exactly because it wasn't treated as FCC.

  1. Bugs in the software itself. For example, this one: Jenkins ZWSP char, which drove me nuts because of the simple fact that after I was building my branch for the first time, in subsequent builds I was using the branch name copied from the CI UI itself while I was monitoring its progress, and it included ZWSP. This defect was solved in a more recent version of Jenkins, but no-one upgraded it and it ate a lot of days and nerves until I finally discovered the problem myself (after an architect from our team looked into the failure and somehow observed the ZWSP in the branch name and suggested me to investigate how it got there).
  2. Docker not starting, due to bad physical machines, corrupted images etc. You just get errors like: Unable to build image, failed to export image, failed to set parent: sha256: ... unknown parent image ID. If Docker does not start, you obviously do not get any Integration Tests executed, any REST tests or any other test types which require live machine. Another cause for Docker not starting might be that your fellow developers created a git branch with special characters and your DevOps colleagues actually used branch name to create docker container. In that case, it will fail with errors like: "Invalid container name..., only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed.
  3. Limited build history. When you build your code, the Custom CI build is available for a limited number of builds due to resource limitation. If there are lots of people using Custom CI, in several hours your build might be already deleted and you would probably not remember anything from it. You need this history saved somewhere, as in this case you don't care about artifacts, like in Main CI.
  4. Random, flaky tests. Zero predictability. You need to figure out if those tests that failed are actually related to what you did or not. And this is hard. There are lots of reasons why tests might be flaky: parallel execution issues, network dependency, temporal coupling, bad implementation etc.
  5. Missing functionality to compare custom builds between them. Because Custom CI builds will be executed by random people for different branches, the Jenkins functionality of showing you difference from last build, at the least, becomes useless. As such, you need a way to compare the results of your build to some reference build.
  6. Guarantee of two consecutive builds for one user, in case point 5 functionality is missing. In order to achieve that, you actually need two consecutive builds: before your changes and after. You might need to execute them sequentially and very fast, in order to make sure no-one else builds in between any other branch.
  7. Custom branches builds must be seeded from custom branches code, not from master. If your CI configuration source code is located in the same repository as your project and you seed if from your master branch, building of custom branch might fail. The reason is simple, the configuration in master might be changed and not compatible anymore with what you have in custom branch. This results in complete impossibility to build any old branch.
  8. Aborted builds, either because of test failure rules (abort after 1% of tests failing) or anything else.
  9. Slow builds due to ever growing test count or simply badly implemented or non-optimized tests.
  10. Because of most of the points described above, engineers can spam Custom CI with several build requests with the intent to make sure that at least one of them succeeds. This results in the increased build queue size and needless resource abuse, besides the fact that, depending on the available resources, you might not get your build being executed and finished for hours.

Continuous integration, be it Main or Custom, sounds cool when you just talk about it on a high level, and it might be perceived as a one time task that it is easily ignorable after it is made to work, but actually it is not. 

CI maintenance and configuration is a day to day job. You need full time people for that, and more than one, in order, at least, to avoid the bus factor

CI must be:

  1. Timely upgraded
  2. Properly maintained
  3. Carefully evolved

 ... and obviously tailored to your organizational needs, and especially to your engineers needs.

I honestly believe that the most important task of the CI is to protect your engineers creativity, productivity and pro-activity, while giving them fearless freedom so they can use their time the best they can in order to bring success to your organization. Indirectly, this safeguards everything else.

If you do not find these reasons within the ones that made you use CI, in my opinion, your are probably doing it wrong.

As for the above problems, the general recommendations are:

  • Monitor CI tool change log and upgrade it
  • Invest time in understanding your virtualization software specifics and known problems. Understand and improve your network.
  • Extract build history and maintain it for a longer period of time, like 30 days or so.
  • Invest in fixing your tests. There is no worse scenario than trying to figure out what is going on, except for the case when you have wrong tests testing wrong stuff in a wrong way.
  • Provide functionality for build comparison, either by doing it in a third party tool, or implement it yourself, if possible.
  • Provide an interface to build 2 branches at once or think of solutions to avoid too many builds. Potential solution might be creating checkpoints for master that should be used as starting point for custom branches, while providing the build for it. I've never done this, but I believe it might actually work. The toughest part would be to educate the engineers
  • Seed your branch build logic from custom branch source code. Breaking this rule results in failed builds due to crazy reasons that will be hard for you to understand and debug. After countless hours you might find out that some DevOps colleague did push breaking changes and you need to rebase master into your branch. Again.
  • Investigate aborted builds and choose your abort threshold carefully.
  • Split tests into priority and criticality categories. The ones that are passing for a long time already can be delegated to nightly builds and avoided in custom, while those that fail often or are very important for the health of the product should be executed always.

I am an avid advocate for using Custom CI as much as possible. 

Many of these recommendations came from my own experience and conclusions, while others I learned from my wonderful colleagues who gladly shared their own experience with me, for which I am extremely grateful.

 

Saturday, April 9, 2022

Demo Data Nightmare, the beginning

- So what do you think about me taking this task and implementing it before anything else on that topic gets to the team's backlog?

- Sounds cool! 

- This means that I can help everyone, once I'm done, on similar tasks. 

- Yeah, that would be great. I think we should do that. 

This is the quick summary of the discussion that started it all, 7 months ago, with my manager, without anything, even slightly pointing to the months of endless work, rework, overwork and ultimately unhealthy stress that were going to hit me.

The task was pretty simple. Based on some existing custom framework, implement a new widget that is going to show some data as a graph. In theory, I shouldn't have done anything even remotely close to rocket science, as my job was to understand how the existing framework works and how it can be reused for different scenarios.

I started investigating, and while the existing framework wasn't as good as I would have expected it to be, especially for something that is to be used so many times and in so many places, it wasn't horrible. I had to copy some generic JSON that is going to define the overall widget configuration, change some parameters, tinker its configuration types to accept my scenario, put it in a specific file, fiddle with the new UI to-be-displayed parameters and voilà, task done. Best case scenario, a week of work, worst case scenario 2 to 3 weeks, depending on the feedback I should be getting from the Functional Architects (FAs), my load on helping the team with all they need and anything that might come along.

After several hours of wandering through project code, short calls with people that already used the framework and code owners, I found myself face to face against the normal situation in which I actually needed the data my widget will be based upon. The bummer about it was the fact that the data was provided by a fairly new and still in development feature and you had to spend many hours or even days in order to generate it, as it depended on some entity state from within the system that you had to actually change, from time to time. The more time you spend on it, the more data you get. There was no way to speed this up. Everyone was waiting to get the data, and so seemed should I. Many were complaining about this, with no effect.  

The whole thing was aggravated by the fact that we have 2 splits per week and usually they are not compatible. If you git pull main branch and then you try to rebase it into your feature branch, you need to recreate the whole database, and obviously everything you generated will be gone.

The prospect of wasting half of my day on generating data, two times a week, didn't sound very pleasing, and as such, the lazy programmer within me said:

- I cannot work like that. I need DEMO DATA!

So, let's snapshot the situation: An experienced engineer gets a task, with a worst case estimation of 3 weeks of work and probably 24 hours of wasting time on generating demo data. In Enterprise terms, 24 hours is basically nothing. But still, laziness in software engineering is not, usually, about time, but about doing the same repetitive task again and again knowing that it can be automated.

What can be automated, eventually will be automated. The only question is: "Who will do it and when?"

In this specific case it was me who thought and really considered that it is better to automate the data generation now, rather than "waste" those 24 hours, especially because I heard several colleagues complain about the same problem as myself.

On occasions like that you imagine yourself, at the end of the task, as Tony Stark presenting some new tech in front of the cheering crowd, bringing something to the table no one was able to, something that will improve everyone's professional day to day life.

(photo Copyright Marvel, Iron Man 2)

And just like that, it all began.