public static byte[] serializeObject(Object o) throws IOException {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos)) {
            oos.writeObject(o);
            oos.flush();
            return baos.toByteArray();
        }
    }
Utility class to create instances from class objects and checking failure reasons.

<p>Copied from Flink project.</p>
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/util/InstantiationUtil.java