How is it possible that the "foo" exception is not thrown, but a subsequent call of invoke() throws the below exception?
if (method.getDeclaringClass() != object.getClass())
throw new RuntimeException("foo");
method.invoke(object);
Thrown exception:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)