try {
if (object instanceof SuperCodable) {
((SuperCodable) object).preEncode();
}
Class objectClass = object.getClass();
CodableClassInfo classInfo = Fields.getClassFieldMap(objectClass);
if (objectClass.isArray()) {
encodeArray(object, objectClass, buf);
} else if (classInfo.size() == 0 && !(object instanceof Codable)) {
encodeNative(object, buf);
} else {
buf.out.write(1);
writeStringHelper(classInfo.getClassName(object), buf.out());
for (Iterator<CodableFieldInfo> fields = classInfo.values().iterator(); fields.hasNext();) {
CodableFieldInfo field = fields.next();
long beginSize = buf.out.size();
encodeField(field.get(object), field, buf, statistics);
if (statistics != null) {
long endSize = buf.out.size();