public static void writeObject(Object obj, SerializationInfo info) { try { boolean replaced = false; Class cl = obj.getClass(); ObjectStreamClass desc; for (; ; ) { Class repCl; desc = ObjectStreamClass.lookup(cl, true); if (!desc.hasWriteReplaceMethod() || (obj = desc.invokeWriteReplace(obj)) == null || (repCl = obj.getClass()) == cl) { break; } cl = repCl; replaced = true; } if (replaced) { info.AddValue("obj", obj); info.SetType(ikvm.runtime.Util.getInstanceTypeFromClass(ReplaceProxy.class)); } else { new InteropObjectOutputStream(info, obj, cl, desc); } } catch (IOException x) { ikvm.runtime.Util.throwException(new SerializationException(x.getMessage(), x)); } }