vendredi 2 décembre 2016

Is it possible to invoke a method with Java reflection with a list of parameters?

I want to insert at run-time the parameters for a method invoked with reflection. In the following non-working example it is showed what I would like to accomplish:

Class[] classes; //array of classes of the parameters
Object[] paramaters; //array of objects containing the values of the parameters

//other stuff happening here

Method method = c.getMethod(met, classes);

method.invoke(o, parameters);

Thank you in advance





Aucun commentaire:

Enregistrer un commentaire