Retrieving parameter values through reflection

巧了我就是萌 提交于 2019-12-31 03:38:06

问题


I am trying to come up with a design for a method that takes another method as a parameter and retrieves the parameter values of the method passed. How can this be done? I've tried using java.lang.reflect.* but can't seem to find an API that supports this.


回答1:


You can't really get the values passed as parameters like this.

You can make your own Proxy and from there capture parameters before calling the right method. Or with aspect you could get the parameters value directly when the method is called.




回答2:


Method.getParameterTypes

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/reflect/Method.html#getParameterTypes%28%29



来源:https://stackoverflow.com/questions/3874894/retrieving-parameter-values-through-reflection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!