How do I get the underlying type of a proxy object in java?

前端 未结 7 1130
旧时难觅i
旧时难觅i 2020-12-09 02:05

I\'d like to access the classname of the underlying class which is an instance of java.lang.reflect.Proxy.

Is this possible?

7条回答
  •  鱼传尺愫
    2020-12-09 02:45

    You can get the InvocationHandler with which the proxy was created, by calling Proxy.getInvocationHandler(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)
    • invocation handler

    And the wrapped class is usually passed to the concrete invocation handler.

提交回复
热议问题