RFR: 8361497: Scoped Values: orElse and orElseThrow do not access the cache

Andrew Haley aph at openjdk.org
Mon Jul 7 16:19:20 UTC 2025


Neither `ScopedValue.orElse` nor `ScopedValue.orElseThrow` consult the cache when searching for a binding. Neither do they update the cache when a binding is found.
While this issue does not affect spec compliance, it is surprising to users that `x.orElse(other)` should be slower than `x.isBound ? x.get() : other`.

-------------

Commit messages:
 - 8361497: Scoped Values: orElse and orElseThrow do not access the cache
 - Merge branch 'master' into JDK-8361497
 - 8361497: Scoped Values: orElse and orElseThrow do not access the cache

Changes: https://git.openjdk.org/jdk/pull/26164/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26164&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8361497
  Stats: 100 lines in 2 files changed: 85 ins; 0 del; 15 mod
  Patch: https://git.openjdk.org/jdk/pull/26164.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26164/head:pull/26164

PR: https://git.openjdk.org/jdk/pull/26164


More information about the core-libs-dev mailing list