if (activator instanceof RemoteObject) {
ref = ((RemoteObject) activator).getRef();
} else if (Proxy.isProxyClass(activator.getClass())) {
InvocationHandler handler = Proxy.getInvocationHandler(activator);
if (!(handler instanceof RemoteObjectInvocationHandler)) {
throw new InvalidObjectException(
"unexpected invocation handler");
}
ref = ((RemoteObjectInvocationHandler) handler).getRef();
} else {
throw new InvalidObjectException("unexpected activator type");
}
out.writeUTF(ref.getRefClass(out));
ref.writeExternal(out);
}