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 testBigMetaEncoding() {
    for (Class<?> type :
        new Class[] {
          MapFields.class, BeanA.class, Struct.createStructClass("TestBigMetaEncoding", 5)
        }) {
      Fury fury = Fury.builder().withMetaShare(true).build();
      ClassDef classDef = ClassDef.buildClassDef(fury, type);
      ClassDef classDef1 =
          ClassDef.readClassDef(
              fury.getClassResolver(), MemoryBuffer.fromByteArray(classDef.getEncoded()));
      Assert.assertEquals(classDef1, classDef);
    }
  }