Why do I get “object is not an instance of declaring class” when invoking a method using reflection?

When you invoke a method via reflection, you need to pass the object you are calling the method on as the first parameter to Method#invoke.

// equivalent to s1.testParam("", obj)
testParamMethod.invoke(s1, "", obj);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)