lundi 20 juillet 2020

Get IllegalArgumentException when invoking method from java agent

I'm trying to call a class method from a java agent, but I keep getting a IllegalArgumentException error.

This is my code:

Class cls = Class.forName("class"); 

Method method = cls.getDeclaredMethod("stringMethod", String.class); 

method.invoke(cls, "example string");

And this is the error I get:

java.lang.IllegalArgumentException: object is not an instance of declaring class

I'm able to get the class and the method, but invoking the method causes the error. Does anyone know what's causing this or how I can fix it?





Aucun commentaire:

Enregistrer un commentaire