Instead of using asInterfaceInstance
, you may use a class augmentation which is described later in this
documentation. In short, it allows you to call a to
method on instances of MethodHandle
, which
in turn calls asInterfaceInstance
. Back to the previous examples, the next 2 lines are equivalent:
# Calling asInterfaceInstance future = executor: submit(asInterfaceInstance(Callable.class, -> "hey!")) # Using a class augmentation future = executor: submit((-> "hey!"): to(Callable.class))