How to unwrap the original object from a dynamic proxy

后端 未结 3 616
借酒劲吻你
借酒劲吻你 2021-01-11 15:53

what\'s the best approach to unwrap a dynamic proxy to retrieve the original object beneath? The dynamic proxy has been created using java.lang.reflect.Proxy.newProxyI

3条回答
  •  庸人自扰
    2021-01-11 16:32

    Each proxy has an InvocationHandler associated with it. Only the InvocationHandler knows which object (if any) underlies the proxy. If you control the creation of the proxy, then you can supply your own InvocationHandler that will have the extra functionality that you desire (i.e. will be able to disclose the underlying object.) If you don't, then I am afraid you're out of luck.

提交回复
热议问题