如何获取Java代理的调用处理程序?

rip*_*234 4 java reflection proxy

鉴于:

Object innerProxy = ...
Object proxy = java.lang.reflect.Proxy.
                newProxyInstance(Thread.currentThread().getContextClassLoader(),
                                 new Class[]{type},
                                 innerProxy);
Run Code Online (Sandbox Code Playgroud)

如何从中提取innerProxy对象proxy

axt*_*avt 15

你可以使用Proxy.getInvocationHandler():

InvocationHandler innerProxy = Proxy.getInvocationHandler(proxy);
Run Code Online (Sandbox Code Playgroud)