lundi 24 septembre 2018

NoSuchMethod exception observed when I tried to access private method from third party jar

I have some private method inside a jar file due to some restriction of visibility to outer class. I just added that jar file through maven dependency. And I want to call that private method and return the value after invoke. but when I tried to execute below code throws NoSuchMethod Exception.

Code:

  Method method = BankFlowTestExecutor.class.getDeclaredMethod("executeBatchCommand", String.class);
  method.setAccessible(true);

The exception observed as soon as its executed the first line in the above code.

Exception:

java.lang.NoSuchMethodException: com.paypal.test.executeBatchCommand(java.lang.String) at java.lang.Class.getDeclaredMethod(Class.java:2130)

Any leads?





Aucun commentaire:

Enregistrer un commentaire