field.setAccessible(true);
map.put(field.getName(), field);
}
SerializableField[] fields = new SerializableField[objectStreamFields.length];
for (int i = 0; i < objectStreamFields.length; i++) {
ObjectStreamField field = objectStreamFields[i];
final String name = field.getName();
final Field realField = map.get(name);
if (realField != null && realField.getType() == field.getType()) {
// allow direct updating of the field data since the types match
fields[i] = new SerializableField(field.getType(), name, field.isUnshared(), realField);
} else {
// no direct update possible
fields[i] = new SerializableField(field.getType(), name, field.isUnshared(), null);
}
}
Arrays.sort(fields, NAME_COMPARATOR);
return fields;
}
final ArrayList<SerializableField> fields = new ArrayList<SerializableField>(declaredFields.length);
for (Field field : declaredFields) {
if ((field.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) {
field.setAccessible(true);
fields.add(new SerializableField(field.getType(), field.getName(), false, field));
}
}
Collections.sort(fields, NAME_COMPARATOR);
return fields.toArray(new SerializableField[fields.size()]);
}