public static byte[] write(Object o) {
    try (ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(arrayOutputStream)) {
      objectOutputStream.writeObject(o);
      return arrayOutputStream.toByteArray();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Write java class to byte array
amoro-format-mixed/amoro-mixed-trino/src/main/java/org/apache/amoro/trino/util/ObjectSerializerUtil.java