Java 12 

Java 12 is a non-LTS feature release. It was the first Java release to include a preview language feature, enabled only with the –enable-preview compiler and JVM flag. Java 12 is end-of-life since September 2019. 

Java 12 Release Details

Release DateMarch 19, 2019
LTSNo
OpenJDK End-of-LifeSeptember 17, 2019
Notable forFirst release with preview features (JEP 12)

Java 12 is end-of-life. Organizations running it should upgrade to a current LTS release: Java 17, Java 21, or Java 25

Java 12 Language Features 

Switch Expressions (Preview, JEP 325) 

The first preview language feature in Java. Switch can now be used as an expression that returns a value, with arrow syntax for single-line branches. This was the preview; switch expressions were finalized in Java 14 (JEP 361). 

// Java 12 preview syntax (required –enable-preview) 

int numLetters = switch (day) { 

    case MONDAY, FRIDAY, SUNDAY -> 6; 

    case TUESDAY                -> 7; 

    case THURSDAY, SATURDAY     -> 8; 

    default                     -> throw new IllegalStateException(“Unexpected: ” + day); 

}; 

Java 12 API Changes 

JVM Constants API (JEP 334) 

A standard API for modeling nominal descriptors of class-file and runtime artifacts: classes, methods, fields, and constant pool entries. The java.lang.constant package provides types like ClassDesc, MethodTypeDesc, and MethodHandleDesc. Used internally by condy (dynamic constants, JEP 309, Java 11) and the java.lang.invoke API. 

This API is primarily for compiler and runtime authors. Application developers rarely interact with it directly. 

Java 12 JVM Changes 

Shenandoah Garbage Collector (JEP 189) 

Low-pause garbage collector from Red Hat. Shenandoah performs evacuation work concurrently with running application threads, targeting pause times independent of heap size. An application with a 100 GB heap sees similar pause times to one with a 1 GB heap. 

Shenandoah was an experimental feature in Java 12. It became production-ready in Java 15 (JEP 379). In Java 25, it gained generational mode (JEP 521). 

Other Changes 

ChangeDescription
Default CDS Archives JVM ships with a default class-data-sharing archive, improving startup time without manual java -Xshare:dump 
Microbenchmark Suite Added JMH-based microbenchmark suite to the OpenJDK source tree for contributor use 
Compact Number Formatting java.text.NumberFormat supports compact representations like “1K” and “1M” via getCompactNumberInstance() 
Teeing Collector Collectors.teeing() forwards stream elements to two downstream collectors and merges their results 

Java 12 Upgrade Path 

Java 12 has been end-of-life since September 2019. No security patches or bug fixes are available. Recommended upgrade targets: 

  • Java 17 LTS: Minimum recommended LTS. Includes sealed classes, pattern matching for instanceof, records, and strong encapsulation of JDK internals 
  • Java 21 LTS: Adds virtual threads, pattern matching for switch, record patterns, and generational ZGC 
  • Java 25 LTS: Current LTS. Adds scoped values, compact source files, AOT method profiling, and compact object headers 

Run jdeps –jdk-internals against your Java 12 application to identify dependencies on encapsulated APIs before upgrading. 

Azul Java 12 Support 

Azul Platform Core provides TCK-certified builds of current LTS releases with extended support. A single subscription covers all supported versions from Java 6 through Java 26

Platform Core wide 1x

Contact Us

Contact us to learn more about our migration services, support, modernization services, and more!