org.linkedin.util-core/src/main/java/org/linkedin/util/reflect/ReflectUtils.java
@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;

  }
@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;

  }
@ 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.

@param proxy
@return the proxied object (or proxy if not an object proxy)
Given a proxy returns the object proxied . If the object is not a proxy then return the object itself .