}
final Class<? extends Object> objClass = replaced.getClass();
final SerializableClass info = registry.lookup(objClass);
if (replace) {
if (info.hasWriteReplace()) {
replaced = info.callWriteReplace(replaced);
}
replaced = objectResolver.writeReplace(replaced);
if (replaced != orig) {
Object clone = clone(replaced, false);
clones.put(orig, clone);