通过反射检索参数值 [英] Retrieving parameter values through reflection

查看:95
本文介绍了通过反射检索参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为一个方法设计一个方法,该方法将另一个方法作为参数并检索传递的方法的参数值。如何才能做到这一点?我已经尝试使用 java.lang.reflect。* 但似乎无法找到支持此功能的API。

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.

推荐答案

你不能真正得到像这样的参数传递的值。

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.

这篇关于通过反射检索参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆