@Override
  public void invokeToData(Object ds, DataOutput out) throws IOException {

    final SerializationContext context = new SerializationContextImpl(out, this);

    boolean isDSFID = ds instanceof DataSerializableFixedID;

    if (!isDSFID) {
      if (ds instanceof BasicSerializable) {
        ((BasicSerializable) ds).toData(out, context);
        return;
      }
      throw new IllegalArgumentException(
          "Expected a DataSerializableFixedID but found " + ds.getClass().getName());
    }

    try {
      boolean invoked = false;
      KnownVersion v = context.getSerializationVersion();

      if (!KnownVersion.CURRENT.equals(v)) {
        // get versions where DataOutput was upgraded
        SerializationVersions sv = (SerializationVersions) ds;
        KnownVersion[] versions = sv.getSerializationVersions();
        // check if the version of the peer or diskstore is different and
        // there has been a change in the message
        if (versions != null) {
          for (KnownVersion version : versions) {
            // if peer version is less than the greatest upgraded version
            if (v.compareTo(version) < 0) {
              ds.getClass().getMethod("toDataPre_" + version.getMethodSuffix(),
                  new Class[] {DataOutput.class, SerializationContext.class})
                  .invoke(ds, out, context);
              invoked = true;
              break;
            }
          }
        }
      }

      if (!invoked) {
        ((DataSerializableFixedID) ds).toData(out, context);
      }
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException
        | InvocationTargetException e) {
      throw new IOException(
          "problem invoking toData method on object of class" + ds.getClass().getName(), e);
    }
  }
For backward compatibility this method should be used to invoke toData on a DSFID.
It will invoke the correct toData method based on the class's version
information. This method does not write information about the class of the object. When
deserializing use the method invokeFromData to read the contents of the object.

@param ds the object to write
@param out the output stream.
geode-serialization/src/main/java/org/apache/geode/internal/serialization/internal/DSFIDSerializerImpl.java