Use StableValue behind Lazy
          #3371
        
          
      
                
     Closed
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Update: JEP 502's successor is a draft for
LazyConstantshttps://openjdk.org/jeps/8359894 with a much more aligned API.We now use Java's
StableValueto back ourLazyimplementation.StableValuesuggests an Optional orElse…(…) usage pattern and it is not primarily intended for lazifying value resolution, therefore we have to mimicStableValue.supplier(…).An immediate benefit is that Java 25++ users will get concurrency guarding while our
Lazyimplementation uses a best effort non-locking approach for value resolution that may observe race conditions as we don't guarantee singleSupplieraccess for the backing supplier object.We're using Java's preview features through a multi-release jar keeping our Java 17 baseline but enabling Java 25
StableValuefeature consumption. Using the4.0.0-STABLE-VALUE-SNAPSHOTversion requires enabling Java preview features during compilation and runtime.