Chapter 5. OpenJDK enhancements

OpenJDK 17 provides enhancements to features originally created in previous releases of OpenJDK.

Dynamic Class Data Sharing (CDS) archives

OpenJDK 17 extends application class-data sharing that enables dynamic archiving of classes at the end of Java program execution. The archived classes now include all loaded application classes and library classes. These classes were not available in the default base-layer CDS archive.

For more information about Dynamic CDS archives, see JEP 350: Dynamic CDS Archives.

Floating-point operations

OpenJDK 17 sets floating-point operations to be consistently strict with the strictfp semantic, which is a change from the traditional default setting of strictfp semantics and the subtly different default floating-point semantics.

The strictfp semantic restores the original floating-point semantics to the language and virtual machine (VM) that match the semantics introduced before strict and default floating-point modes in Java SE 1.2.

For more information about floating-point operations, see JEP 306: Restore Always-Strict Floating-Point Semantics.

G1 garbage collector (GC)

OpenJDK 17 enhances the G1 GC with the following capabilities:

  • Abort mixed collections if these collections exceed the set paused time.
  • Implement Non-Uniform Memory Access (NUMA) aware memory allocation.
  • Return unused committed memory automatically from heap memory to an idle operating system.

For more information about aborting mixed collections, see JEP 344: Abortable Mixed Collections for G1.

For more information about NUMA-aware memory allocation for the G1 GC, JEP 345: NUMA-Aware Memory Allocation for G1.

For more information about returning unused committed memory from the G1 GC, see JEP 346: Promptly Return Unused Committed Memory from G1.

Legacy DatagramSocket API

OpenJDK 17 replaces the underlying implementations of the and APIs with a new implementation. The new implementation includes the following enhancements:

  • Better compatibility with virtual threads.
  • Easier maintenance and debug offerings.
  • Simpler implementation.

For more information about the Legacy DatagramSocket API, see JEP 373: Reimplement the Legacy DatagramSocket API.

For more information about virtual threads, see Loom - Fibers, Continuations and Tail-Calls for the JVM.

Legacy Socket API

OpenJDK 17 replaces the implementation used by the and APIs with a new implementation. The new implementation includes the following enhancements:

  • Better compatibility with user-mode threads, such as fibers.
  • Easier maintenance and debug offerings.
  • Simpler implementation.

For more information about the reintroduction of the Legacy Socket API, see JEP 353: Reimplement the Legacy Socket API.

For more information about fibers, see Loom - Fibers, Continuations and Tail-Calls for the JVM.

Helpful NullPointerExceptions

OpenJDK 17 improves the use of NullPointerException exceptions that were generated by the Java Virtual Machine (JVM) by precisely describing where the null value occurred when the exception was raised.

For more information about improvements to NullPointerException exceptions, see JEP 358: Helpful NullPointerExceptions.

Shenandoah garbage collector

OpenJDK 17 improves the Shenandoah garbage collector (GC). Shenandoah can now reduce GC pause times by running concurrently with Java threads.

With OpenJDK 17, the Shenandoah GC can achieve sub-millisecond pause times. Pause times with Shenandoah are independent of the Java heap size.

For more information about the Shenandoah GC, see JEP 379: Shenandoah: A Low-Pause-Time Garbage Collector.

Strongly encapsulate JDK internals

OpenJDK 17 provides a stronger encapsulation mechanism for internal elements of JDK by default, except critical internal APIs, such as sun.misc.Unsafe.

In previous releases of OpenJDK, you could reduce the level of encapsulation for all internal JDK elements, such as critical and non-critical elements. You cannot reduce this level of encapsulation for internal elements in OpenJDK 17.

For more information about strongly encapsulating internal elements of JDK, see JEP 403: Strongly Encapsulate JDK Internals.

Switch expressions

OpenJDK 17 extends the capability of the switch statement, so you can use it either in statement form or in expression form. This capability simplifies coding and provides some pattern matching capabilities with the switch expression.

Both forms support traditional and simplified scoping and control flow behavior. Additionally, both forms can use either the traditional case…​ : labels or the new case…​ → labels, with new statements providing a value from a switch expression.

Additionally, OpenJDK 17 supports extending pattern matching to switch, so that you can test an expression against a number of patterns, each with a specific action, so that you can perform complex data-oriented queries concisely and safely. For OpenJDK 17, this feature is available as Technology Preview only.


For OpenJDK 17, extending pattern matching to switch is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

For more information about switch expression capabilities, see JEP 361: Switch Expressions.

For more information about Java-related technology preview features, see JEP 12: Preview Features.