dimanche 2 avril 2017

Passing values List as parameter a function

Im working on a Java class by using reflection, I have a list of different type of objects:

public List MethodSignatureObjects

and, I need to invoke a method by using the folowing logic:

   Class<?> c = Class.forName("class name");
   Method  method = c.getDeclaredMethod ("method name", parameterTypes)
   method.invoke (objectToInvokeOn, params)

Is there any way to put the objects contained on MethodSignatureObjects on getDeclaredMethod, I mean, something like this:

Method method = c.getDeclaredMethod (methodName, param1.class, param2.class, ..); where parameters1 , parameters2, parameter n.... come from MethodSignatureObjects

I really appreaciate any advise.

Thank you so much.





Aucun commentaire:

Enregistrer un commentaire