public static @NotNull <T> T castToLocal(@Nullable Object remote, @NotNull Class<T> clazz) {
    if (clazz.isInstance(remote)) return clazz.cast(remote);
    ClassLoader loader = clazz.getClassLoader();
    return ReflectionUtil.proxy(clazz, new RemoteInvocationHandler(remote, clazz, loader));
  }
public static @NotNull <T> T castToLocal(@Nullable Object remote, @NotNull Class<T> clazz)