lundi 19 décembre 2016

Java reflection API : How to get the list of Parameters in a method before trying to invoke it

I'm trying to invoke methods stored in an excel file. Got stuck when i could not solve the problem while trying to get the list of parameters before invoking the method. Some of methods have int,few have string and the rest have both

//read excel file using poi API, so assuming the method name is LaunchBrowser

MyClass c = new MyClass();

Class classObj = c.getClass();

Method[] m1 = classObj.getDeclaredMethods();

Class[] parameterTypes = m1[0].getParameterTypes();

System.out.println(parameterTypes[0]);

Method gs1Method = classObj.getMethod("LaunchBrowser",new Class[] {parameterTypes}); // got stuck here





Aucun commentaire:

Enregistrer un commentaire