}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// write a marker to stream to distinguish from null value stream
baos.write(SERIALIZABLE_VALUE);
MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(baos);
mvos.writeObject(obj);
mvos.flush();
return baos.toByteArray();
}