[Java] IllegalArgumentException of method inflection

阅读更多
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.

你可能感兴趣的:(Java)