try {
stream = new ObjectOutputStream(new OutputStream() {
public void write(int b) {}
});
} catch (IOException cannotHappen) {
}
if (!(obj instanceof Serializable)) {
return false;
}
try {
stream.writeObject(obj);
} catch (IOException e) {
return false;
} finally {
// Fix for 4503661.
// Reset the stream so that it doesn't keep a reference to the
// written object.
try {
stream.reset();
} catch (IOException e) {
// Ignore the exception.
}
}
return true;