code: void write(ObjectOutputStream out) throws IOException {
          PutField fields = out.putFields();
  
          fields.put(CONTEXT, threadContextDescriptor.serialize());
  
          fields.put(EXEC_PROPS, threadContextDescriptor.getExecutionProperties());
  
          fields.put(INTERNAL_PROP_NAMES, internalPropNames);
  
          ByteArrayOutputStream bout = new ByteArrayOutputStream();
          ObjectOutputStream oout = new ObjectOutputStream(bout);
          oout.writeObject(object);
          oout.flush();
          fields.put(OBJECT, bout.toByteArray());
          oout.close();
  
          out.writeFields();
      }
docs: Serialize.
  
  @param out stream to which to serialize
  @throws IOException if there is an error writing to the stream