$ java ScopedValuesBasics (JDK 25, no preview flag -- JEP 506 is final) CHECK ok : isBound() is true inside where().run() CHECK ok : get() returns "ankur" inside the binding CHECK ok : a method several frames deep, given no parameter, still sees the binding CHECK ok : isBound() is false again once run() has returned CHECK ok : get() outside a binding throws NoSuchElementException, not null or a default value CHECK ok : orElse(fallback) returns the fallback when unbound, no exception CHECK ok : orElse(fallback) returns the real value when bound CHECK ok : orElseThrow(supplier) throws exactly the supplied exception when unbound CHECK ok : outer binding: ankur CHECK ok : inner binding shadows the outer one: support-bot CHECK ok : a method called from inside the inner scope sees the REBOUND value, not the original CHECK ok : outer binding is restored, unchanged, once the inner where() block exits: ankur CHECK ok : call(...) returns whatever the lambda returns -- USER.get().length() == 5 exit=0