TaskHandle.task() is not correctly typed !
    Remi Forax 
    forax at univ-mlv.fr
       
    Sat May 13 06:26:28 UTC 2023
    
    
  
Here is an example that shows that TaskHandle.task() should be typed Callable<? extends T> and not Callable<T>.
The current API is unsound.
interface NonCovariantCallable<T> extends Callable<T> {
  T call() throws Exception;
  void set(T t);
}
...
try(var scope = new STS<Object>()) {
  TaskHandle<Object> handle = scope.fork(new NonCovariantCallable<String>() {
    public String call() {
      return "foo";
    }
    public void set(String s) {}
  });
  scope.join();
  Callable<Object> task = handle.task();
  NonCovariantCallable<Object> nonCovariantTask = (NonCovariantCallable<Object>) task;
  nonCovariantTask.set(3);
}
The last call should throw a CCE in the bridge that calls set(String).
regards,
Rémi
    
    
More information about the loom-dev
mailing list