Want to pass class.getmethod arguments dynamically in run time java

Multi tool use


Want to pass class.getmethod arguments dynamically in run time java
I want to invoke a method by giving methodName in runtime. I can do it in below way.
Method method = MyObject.class.getMethod("doSomething", String.class);
Object returnValue = method.invoke(null, "parameter-value1");
But I want to list down all the methods with that method name and the different set of arguments and let the user choose the method with a particular set of arguments and dynamically pass those arguments in
Method method = MyObject.class.getMethod("doSomething", String.class);
instead of hardcoding String.class.
suppose I have two methods like
methodName(String)
and
methodName(String,int)
I want to let user choose which one to pick in runtime and pass that information for getMethod function for that particular method.
How can I do this?
show all available signatures to the user, let them choose one, and invoke the choice
– Andrew Tobilko
5 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
By querying the methods that a class has. To then check the parameter information. To then show that to the user.
– GhostCat
8 mins ago