public static void writeObject(Object o, DataOutput out, boolean allowJavaSerialization)
      throws IOException {

    if (allowJavaSerialization) {
      writeObject(o, out);
      return;
    }

    DISALLOW_JAVA_SERIALIZATION.set(Boolean.TRUE);
    try {
      writeObject(o, out);
    } finally {
      DISALLOW_JAVA_SERIALIZATION.set(Boolean.FALSE); // with JDK 1.5 this can be changed to
                                                      // remove()
    }
  }
Writes an arbitrary object to a <code>DataOutput</code>. If <code>o</code> is not an instance
of a specially-handled standard Java class (see the list in {@link #getSupportedClasses}), the
{@link DataSerializer#toData toData} method of each registered <code>DataSerializer</code> is
invoked until the object is serialized. If no registered serializer can serialize the object
and <code>o</code> does not implement <code>DataSerializable</code>, then it is serialized to
<code>out</code> using standard Java {@linkplain java.io.Serializable serialization}. This
method will serialize a <code>null</code> o and not throw a <code>NullPointerException</code>.

@param o the object to write
@param out the {@link DataOutput} to write to
@param allowJavaSerialization If false, then a NotSerializableException is thrown in the case
       where standard Java serialization would otherwise be used for object <code>o</code> or
       for any nested subobject of <code>o</code>. This is used to prevent Java serialization
       from being used when sending data to a non-Java client
@throws IOException A problem occurs while writing <code>o</code> to <code>out</code>

@see #readObject(DataInput)
@see Instantiator
@see ObjectOutputStream#writeObject
geode-core/src/main/java/org/apache/geode/DataSerializer.java