`
SilverRing
  • 浏览: 71041 次
社区版块
存档分类
最新评论

[Java] IllegalArgumentException of method inflection

    博客分类:
  • Java
阅读更多
If this exception is encountered:

java.lang.IllegalArgumentException: object is not an instance of declaring class


Check whether the object instance is correct:

Method method = invoker.getClass().getMethod("testMethod");
method.invoke(invoker); // must be invoker, don't set "this"


invoker is the instance of the object that testMethod is defined in.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics