如何在java中获取代理对象的基础类型? [英] How do I get the underlying type of a proxy object in java?
本文介绍了如何在java中获取代理对象的基础类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想访问基础类的类名,该类是 java.lang.reflect.Proxy
的实例。
I'd like to access the classname of the underlying class which is an instance of java.lang.reflect.Proxy
.
这可能吗?
推荐答案
你可以得到 InvocationHandler
用于创建代理,通过调用 Proxy.getInvocationHandler(代理)
You can get the InvocationHandler
with which the proxy was created, by calling Proxy.getInvocationHandler(proxy)
请注意 java.lang.reflect.Proxy
的情况本身没有底层类。代理定义如下:
Note that in the case of java.lang.reflect.Proxy
there is no underlying class per se. The proxy is defined by:
- interface(s)
- 调用处理程序
包装的类通常会传递给具体的调用处理程序。
And the wrapped class is usually passed to the concrete invocation handler.
这篇关于如何在java中获取代理对象的基础类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文