JDK 12 · JSR 386

Java 12

JDK 12 is Java SE 12, JSR 386, generally available on 19 March 2019. There is no new permanent language feature. Switch expressions are a preview. Shenandoah is an experimental collector. G1 gains two latency-oriented changes.

How to read the status

Language

Switch Expressions (Preview)

JEP 325 · Preview · Language

A switch can be an expression that yields a value. The preview form is disabled unless preview features are enabled.

Preview again in Java 13 (JEP 354). Standard in Java 14 (JEP 361).

OpenJDK JEP 325 (leaves JavaMastery)

Related reading: Control flow

JVM / Runtime

Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)

JEP 189 · Experimental · JVM / Runtime

Shenandoah does evacuation work concurrently to keep pauses short. In Java 12 it is experimental.

It becomes a product feature in Java 15 (JEP 379).

OpenJDK JEP 189 (leaves JavaMastery)

Related reading: JVM and memory

Abortable Mixed Collections for G1

JEP 344 · Final · JVM / Runtime

G1 can abort a mixed collection that is taking too long, so a pause is more likely to meet its goal.

OpenJDK JEP 344 (leaves JavaMastery)

Promptly Return Unused Committed Memory from G1

JEP 346 · Final · JVM / Runtime

G1 can return unused Java heap memory to the operating system during idle time.

OpenJDK JEP 346 (leaves JavaMastery)

Default CDS Archives

JEP 341 · Final · JVM / Runtime

The JDK ships a default class-data sharing archive, so the feature is available without a separate dump step.

OpenJDK JEP 341 (leaves JavaMastery)

Examples

  • versions5Java17Features.javaCumulative Java 12–17 example · Requires Java 17Final forms only: switch expressions from Java 14, text blocks from Java 15, records and instanceof patterns from Java 16, and sealed classes from Java 17. This is not a Java 12 preview program. Pattern matching for switch was still a preview in Java 17 and is not used.

Related reading

Historical notes

The final switch-expression syntax is in the Java 17 cumulative example, which is not a Java 12 program. Java 12’s own switch work was a preview.

Sources. General availability, JSR 386, and the JEP list: OpenJDK JDK 12. OpenJDK JDK 12 (leaves JavaMastery)

All versions