How can I get the invocation handler for a Java proxy?
Given:
Obj开发者_JAVA技巧ect innerProxy = ...
Object proxy = java.lang.reflect.Proxy.
newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[]{type},
innerProxy);
How can I extract the innerProxy
object from proxy
?
You can use Proxy.getInvocationHandler()
:
InvocationHandler innerProxy = Proxy.getInvocationHandler(proxy);
精彩评论