code: public static <T> T unproxy(T instance)
    {
      if(instance == null) {
        return null;
      }
      if(!(instance instanceof Proxy)) {
        return instance;
      }
      if(!(Proxy.getInvocationHandler(instance) instanceof InstanceInvocationHandler)) {
        throw new BugError("Cannot unproxy instance |%s|. Proxy handler does not implement |%s|", instance.getClass(), InstanceInvocationHandler.class);
      }
      @SuppressWarnings("unchecked")
      InstanceInvocationHandler<T> handler = (InstanceInvocationHandler<T>)Proxy.getInvocationHandler(instance);
      return handler.getWrappedInstance();
    }
docs: Return wrapped instance of a Java Proxy implemented on a {@link InstanceInvocationHandler} handler. If given
  <code>instance</code> is not a Java Proxy return it as it is and return null if <code>instance</code> is null. It
  is considered a bug if <code>instance</code> is a Java Proxy and its handler does not implement
  {@link InstanceInvocationHandler}.
  
  @param instance instance to unproxy, null accepted.
  @param <T> instance type.
  @return proxy wrapped instance, possible null.
  @throws BugError if Java Proxy handler does not implement {@link InstanceInvocationHandler}.