New candidate JEP: 502: Stable Values (Preview)
Alan Snyder
javalists at cbfiddle.com
Wed Jan 22 21:53:53 UTC 2025
The JEP describes StableValue as a step towards deferred immutability, defined as:
"What we are missing is a way to promise that a field will be initialized by the time it is used, with a value that is computed at most once and, furthermore, safely with respect to concurrency. In other words, we need a way to defer immutability.”
What is the roadmap for getting the rest of the way?
StableValue looks to me like an implementation mechanism, something that someday the compiler and JVM might use.
It does not look like something I would want to use in my source code.
If introduced as a public API, will StableValue be obsolete soon thereafter?
> On Jan 22, 2025, at 7:10 AM, Mark Reinhold <mark.reinhold at oracle.com> wrote:
>
> https://openjdk.org/jeps/502
>
> Summary: Introduce an API for stable values, which are objects that
> hold immutable data. Stable values are treated as constants by the
> JVM, enabling the same performance optimizations that are enabled
> by declaring a field final. Compared to final fields, however,
> stable values offer greater flexibility as to the timing of their
> initialization. This is a preview API.
>
> - Mark
More information about the core-libs-dev
mailing list