-
CSR
-
Resolution: Unresolved
-
P4
-
None
-
minimal
-
The only change proposed is for ScopedValue orElse(null) to throw NullPointerException. Code using the preview API may need to be updated. If nullness markers are introduced in a future release then this method will change to else(T!).
-
Java API
-
SE
Summary
Make java.lang.ScopedValue
a permanent API.
Problem
The motivation section of JEP 506 explains the issues with ThreadLocal
and the motivation for introducing a new API.
Solution
Introduce a simple API that allows a value to be safely and efficiently shared to methods without using method parameters. The unfolding execution of the methods define a dynamic scope. This scope is not just that of a single thread: it extends to allow scoped values in a parent thread to be automatically inherited by child threads created with java.util.concurrently.StructuredTaskScope
.
The classes in the API are as follows:
java.lang.ScopedValue
java.lang.ScopedValue.Carrier
java.lang.ScopedValue.CallableOp
The 3 classes are in JDK 24 as preview APIs. The only API change that is proposed for JDK 25 is to change the ScopedScope::orElse(V)
method to disallow null
. Additional, the @since
tag on the 3 classes is updated to be 25 (as required by JEP 12).
Specification
Remove the @PreviewFeature annotations. The only other change in this PR is to remove the permission to pass null to orElse().
The diff is attached.
- csr of
-
JDK-8355022 Implement JEP 506: Scoped Values
-
- Open
-