ITeye博客

[Java] IllegalArgumentException of method inflection

SilverRing · 2010-10-19 15:04 · Java · 编程语言 · Markdown

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.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。