public static byte[] serializeObjectWithTypeInformation(Serializable object) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Kryo kryo = borrowKryo();
    try (Output output = new Output(baos)) {
      kryo.writeClassAndObject(output, object);
    } finally {
      releaseKryo(kryo);
    }
    return baos.toByteArray();
  }
Serializes any object via Kryo. Type information will be serialized as well, allowing dynamic deserialization
without the need to pass the class.
@param object The object to serialize.
@return Bytes.
ql/src/java/org/apache/hadoop/hive/ql/exec/SerializationUtilities.java