static ClassDef buildClassDef(
      ClassResolver classResolver, Class<?> type, List<Field> fields, boolean isObjectType) {
    List<FieldInfo> fieldInfos = buildFieldsInfo(classResolver, fields);
    Map<String, List<FieldInfo>> classLayers = getClassFields(type, fieldInfos);
    fieldInfos = new ArrayList<>(fieldInfos.size());
    classLayers.values().forEach(fieldInfos::addAll);
    MemoryBuffer encodeClassDef = encodeClassDef(classResolver, type, classLayers, isObjectType);
    byte[] classDefBytes = encodeClassDef.getBytes(0, encodeClassDef.writerIndex());
    return new ClassDef(
        Encoders.buildClassSpec(type),
        fieldInfos,
        isObjectType,
        encodeClassDef.getInt64(0),
        classDefBytes);
  }
@Test
  public void testEmptySubClassSerializer() {
    Fury fury = Fury.builder().withLanguage(Language.JAVA).requireClassRegistration(true).build();
    ClassDef classDef = ClassDef.buildClassDef(fury, Foo2.class);
    ClassDef classDef1 =
        ClassDef.readClassDef(
            fury.getClassResolver(), MemoryBuffer.fromByteArray(classDef.getEncoded()));

    Assert.assertEquals(classDef, classDef1);
  }