@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
发布于 2014-11-21 16:22:00
查看MethodHandle中的示例-我认为您需要传递要在其上调用方法的实例作为第一个参数
leftButtonClickMethod.invoke(this,list, menuTitle);但是因为我从来没有使用过java.lang.invoke,所以这可能是完全错误的。
https://stackoverflow.com/questions/27020877
复制相似问题