mercredi 28 février 2018

How can I call Method.invoke with an arbitrary number of arguments?

I am building a system in which the user can type names of methods into a text file, and a java program will parse it, invoking methods in a separate class corresponding to the method name typed. The user also types all the arguments to the method in the file. Using Class.getMethods, I know the type and number of arguments that the desired method takes. I do not know how to call Method.invoke with the correct number of arguments given the number of arguments the method takes (which could be any number). Thanks in advance





Aucun commentaire:

Enregistrer un commentaire