@ SuppressWarnings ( "unchecked" ) public static Object getProxiedObject ( Object proxy ) { if ( Proxy . isProxyClass ( proxy . getClass ( ) ) ) { InvocationHandler invocationHandler = Proxy . getInvocationHandler ( proxy ) ; if ( invocationHandler instanceof ObjectProxy ) { ObjectProxy objectProxy = ( ObjectProxy ) invocationHandler ; // recursively fetch the proxy return getProxiedObject ( objectProxy . getProxiedObject ( ) ) ; } else return proxy ; } else return proxy ; }
Given a proxy returns the object proxied . If the object is not a proxy then return the object itself .