0
@FXML private void handleLeftButton() throws Throwable{

MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodType methodType = MethodType.methodType(void.class, ListIterator.class, Text.class);
MethodHandle leftButtonClickMethod = lookup.findVirtual(HomePresenter.class, "leftButtonClick", methodType);

leftButtonClickMethod.invoke(list, menuTitle);

}

为什么我会收到此错误?

java.lang.invoke.WrongMethodTypeException:无法将 MethodHandle(HomePresenter,ListIterator,Text)void 转换为 (ListIterator,Text)void

4

1 回答 1

0

查看 MethodHandle 中的示例-我认为您需要将要调用该方法的实例作为第一个参数传递

leftButtonClickMethod.invoke(this,list, menuTitle);

但是因为我从未使用过 java.lang.invoke 这可能是完全错误的。

于 2014-11-21T08:22:00.340 回答