code: public static void write(ObjectOutput out, Class<?> cl) throws IOException {
          int dim;
  
          if (cl == null) {
              out.writeByte(-1);
          } else {
              dim = 0;
              while (cl.isArray()) {
                  dim++;
                  cl = cl.getComponentType();
              }
  
              if (dim > Byte.MAX_VALUE) {
                  throw new RuntimeException("to many dimensions");
              }
  
              out.writeByte((byte) dim);
              out.writeUTF(cl.getName());
          }
      }
docs: Writes a class Object.
  @param  out target to write to
  @param  cl  class to be written