0

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?

jww
  • 97,681
  • 90
  • 411
  • 885
वरुण
  • 1,237
  • 3
  • 18
  • 50
  • 1
    possible duplicate of [No compatible method found: error while passing object to a method?](http://stackoverflow.com/questions/23171798/no-compatible-method-found-error-while-passing-object-to-a-method) – Seelenvirtuose Aug 21 '14 at 07:54
  • 2
    No, I won't provide it as an answer. You shouldn't even have asked this question as a little search would have brought you to this duplicate. – Seelenvirtuose Aug 21 '14 at 08:52

0 Answers0