【发布时间】:2014-11-21 16:22:00
【问题描述】:
@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
【问题讨论】:
-
可以发
HomePresenter的相关代码吗?我很难理解为什么您使用这种反射方法来调用该方法,而不是仅仅以通常的方式调用它。
标签: java javafx methodhandle