Dev News Daily ENDE

JEP 547 proposes Lazy Constants for JDK 28 as a fourth preview, with no changes to the API

JEP 547, Lazy Constants (Fourth Preview), has the status Proposed to Target for JDK 28. The JEP page was last updated on 11 November, and the JDK 28 project page lists the end of its review period as 18 November 2026. Its authors are Per Minborg and Maurizio Cimadamore, and Mark Reinhold reviewed and endorsed it.

A lazy constant is an object of type java.lang.LazyConstant that holds a single value. It is created with a computing function, usually a lambda or a method reference, is initialized at some point before its content is first read, and cannot be changed afterwards. The JEP says the JVM treats lazy constants as true constants, which allows the same optimizations as a final field while leaving the timing of initialization open. The goals are to let application state be initialized incrementally rather than all at startup, to guarantee initialization at most once even with several threads, and to let user code benefit from constant folding that was previously available only to code inside the JDK. Adding lazy fields to the language and changing the meaning of final are listed as non-goals.

The API has changed several times. It first appeared as a preview in JDK 25 through JEP 502. For JDK 26, JEP 526 removed the low-level methods orElseSet, setOrThrow and trySet, renamed the API from StableValue to LazyConstant, moved the factories for lazy lists and maps into List and Map, dropped the function and intFunction factories and disallowed null as a computed value. For JDK 27, JEP 531 removed isInitialized and orElse and added Set.ofLazy. JEP 547 proposes to preview the API again in JDK 28 with no changes.

The JEP's motivating example is a logger. As a final field it must be created whenever the owning object is, which can slow startup; as a mutable field behind a null-checking getter it introduces an invariant that every access must go through the getter, can create several loggers under concurrency, and cannot be constant-folded by the JVM.

According to the project page, JDK 28 enters Rampdown Phase One on 3 December 2026 and is scheduled for general availability on 9 March 2027.

JEP 547 proposes Lazy Constants for JDK 28 as a fourth preview, with no changes to the API
JEP 547 proposes Lazy Constants for JDK 28 as a fourth preview, with no changes to the API — Dev News Daily

Why it matters

A fourth preview with no changes means the API that JDK 27 users can try today is the one being proposed again. It also means LazyConstant stays a preview API in JDK 28 rather than becoming final in that release.

Primary source
OpenJDK JEPs
https://openjdk.org/jeps/547