Skip to content
Advertisement

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

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

Is this possible?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement