Java Reflection: “java.lang.NoSuchMethodException”

前端 未结 1 1378
逝去的感伤
逝去的感伤 2021-01-29 14:41

I am trying to get the method from another class using reflection, but for some reason it keeps on giving me a no such method exception. These are the classes im using:

1条回答
  •  北海茫月
    2021-01-29 15:21

    This is your problem:

    script.getMethod("scriptInfo()", script);
    

    change it to:

    script.getMethod("scriptInfo");
    

    and look here to see why:

    http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getMethod%28java.lang.String,%20java.lang.Class...%29

    0 讨论(0)
提交回复
热议问题