Why does `ScopedValue.where(SCOPE_VALUE, val).call()` throw Exception?

Andrew Haley aph-open at littlepinkcloud.com
Wed Apr 12 17:20:43 UTC 2023


On 3/23/23 16:59, Holo The Sage Wolf wrote:
> A possibly better solution is to create:
> 
> ```java
>      @FunctionalInterface
>      interface GCallable<R, E extends Throwable> {
>          R call() throws E;
>      }
> ```
> And use this interface.
> It will require changing the signature of `Carrier#runWith` (and hence
> modifying `JVM_FindScopedValueBindings`) and of 3 methods in
> `ScopedValueContainer` (alternatively only changing the signature of
> `Carrier#runWith` and the implementation of `ScopedValueContainer#call`),
> but everything else could be left unchanged, and letting Java infer the
> exception needed.

I can see the logic in doing this, and it would have been nice had Callable
been declared this way, but I don't think I can get away with adding yet
another public Functionalnterface to the Callable and Supplier set.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the loom-dev mailing list