/** * Write the specified object to the ObjectOutputStream. Objects referenced by this object are * written transitively so that a complete equivalent graph of objects can be reconstructed by an * ObjectInputStream. * * <p>Exceptions are thrown for problems with the OutputStream and for classes that should not be * serialized. All exceptions are fatal to the OutputStream, which is left in an indeterminate * state, and it is up to the caller to ignore or recover the stream state. * * @throws IOException Any exception thrown by the underlying OutputStream. */ public final void writeObject(Object obj) throws IOException { try { // Find an appropriate surrogate for the object SerializationSurrogate surrogate = this.mSelector.getSurrogateForObject(obj, _cacheContext); // write type handle Class[] type; if (surrogate instanceof ObjectSerializationSurrogate) { SerializationSurrogate testSurrogate = null; testSurrogate = getType(surrogate, obj.getClass()); if (testSurrogate != null) { surrogate = testSurrogate; } } surrogate.writeHandle(this, obj); if (surrogate.getSubHandle() > 0) surrogate.writeSubHandle(this, obj); surrogate.writeObject(this, obj); } catch (CacheIOException nCacheIOException) { // this.writeObject(obj); throw new IOException(nCacheIOException.toString() + " is not marked as serializable."); } catch (Exception ex) { throw new IOException(ex.toString()); } }