Deencapsulation.invoke()
throws exception with message if I pass an instance of subclass as argument to private method java.lang.IllegalArgumentException: No compatible method found
.
Like this:
Object a = new ClassB();
try
{
Deencapsulation.invoke(someInstance, "someMethod", a);
}
catch(Exception e)
{
e.printStackTrace();
}
Then console shows output:
java.lang.IllegalArgumentException: No compatible method found: someMethod(ClassB)
How do I should call the private method?