private int initFieldsFromClass(Class<?> initClass,
            Map<Integer, FieldConverter> customEncoders,
            HashMap<Integer, FieldConverter> idToFieldMap) {
        int maxFieldId = 0;

        if (!initClass.getSuperclass().equals(Object.class)) {
            maxFieldId = initFieldsFromClass(initClass.getSuperclass(), customEncoders, idToFieldMap);
        }

        for (Field f : initClass.getDeclaredFields()) {
            f.setAccessible(true);
            FieldId ann = f.getAnnotation(FieldId.class);
            if (ann != null) {
                FieldConverter fldConv = null;
                maxFieldId = Math.max(maxFieldId, ann.value());
                if (customEncoders != null) {
                    fldConv = customEncoders.get(ann.value());
                }
                if (fldConv == null) {
                    fldConv = BaseTypeFieldConverterFactory.newInstanceFor(f.getType());
                }
                if (fldConv == null) {
                    if (Collection.class.isAssignableFrom(f.getClass())) {
                        fldConv = new CollectionFieldConverter(new AnnotationBasedByteConverter(f.getClass()));
                    } else {
                        fldConv = new DynamicFieldConverter(new AnnotationBasedByteConverter(f.getClass()));
                    }
                }
                fldConv.configure(f, ann.value());
                idToFieldMap.put(ann.value(), fldConv);
            }
        }

        return maxFieldId;
    }