Is there any way by which we can retrieve all the arguments/parameters of a method inside that method in a Map
with key as parameter name and value as parameter value?
Say, I have a method with below signature:
public void do(String arg1, int arg2, String arg3, Double arg4, MyCustomObj arg5)
I want to achieve something like this:
public void do(String arg1, int arg2, String arg3, Double arg4, MyCustomObj arg5) {
Map<String, Object> argsMap = <what-goes-here>;
logger.info("do ENTRY: "+argsMap);
}
PS: I am not looking for a solution based on AOP. I want something that can be used within the method itself.
Update: This question is not about how to get values via Reflection. Please re-read before marking it as duplicate.