开发者

Retrieving parameter values through reflection

开发者 https://www.devze.com 2023-01-18 19:44 出处:网络
I am trying to come up with a design for a m开发者_如何学JAVAethod that takes another method as a parameter and retrieves the parameter values of the method passed. How can this be done? I\'ve tried u

I am trying to come up with a design for a m开发者_如何学JAVAethod 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.


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.


Method.getParameterTypes

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

0

精彩评论

暂无评论...
验证码 换一张
取 消