bye stable values, enter lazy constants

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Sep 29 09:15:36 UTC 2025


Hi all,
Per and I have been completed another round of preview of the Stable 
Value API. As you might have noticed, the name changed (again!) to 
LazyConstant 🙂

https://openjdk.org/jeps/526

In many ways, the new API is more similar to the old ComputedConstant 
API, as the imperative methods are gone: the only way to create a lazy 
constant is by providing a lambda expression at construction.

The reason behind the change is that, after performing extensive 
experiments with the StableValue API, we have learned that:

* Most use cases could be expressed with a caching supplier. This meant 
that in most cases developers never needed to interact with StableValue 
-- which seemed odd.
* For low-level cases, the imperative API we provided was not low-level 
enough, as it still added significant synchronization and boxing costs. 
This made the API unsuitable to use in performance critical code (such 
as the ClassFile API).

For these reasons we have decided to shift the design center of the API 
back to the most common, functional use cases, which led us to this 
simpler API. That said, the quest for a more fundamental building block 
is not over: we now have a clearer idea on how to expose "stable" access 
to regular fields/array elements, using a _new_ var handle access mode. 
Initial experiments look indeed promising: such an approach doesn't 
require the allocation of intermediate abstractions, and allows clients 
to decide if they want to pay for synchronization or not.

As always, we are very thankful for all the feedback we have received so 
far, and we look forward for some more!

Cheers
Maurizio





More information about the leyden-dev mailing list