nextClass = nextClass.getSuperclass();
}
ObjectMap context = kryo.getContext();
IntArray useAsm = new IntArray();
ArrayList<Field> validFields = new ArrayList(allFields.size());
for (int i = 0, n = allFields.size(); i < n; i++) {
Field field = allFields.get(i);
int modifiers = field.getModifiers();
if (Modifier.isTransient(modifiers)) continue;
if (Modifier.isStatic(modifiers)) continue;
if (field.isSynthetic() && ignoreSyntheticFields) continue;
if (!field.isAccessible()) {
if (!setFieldsAsAccessible) continue;
try {
field.setAccessible(true);
} catch (AccessControlException ex) {
continue;
}
}
Optional optional = field.getAnnotation(Optional.class);
if (optional != null && !context.containsKey(optional.value())) continue;
validFields.add(field);
// BOZO - Must be public?
useAsm.add(!Modifier.isFinal(modifiers) && Modifier.isPublic(modifiers)
&& Modifier.isPublic(field.getType().getModifiers()) ? 1 : 0);
}
// Use ReflectASM for any public fields.
if (!Util.isAndroid && Modifier.isPublic(type.getModifiers()) && useAsm.indexOf(1) != -1) {
try {
access = FieldAccess.get(type);
} catch (RuntimeException ignored) {
}
}
ArrayList<CachedField> cachedFields = new ArrayList(validFields.size());
for (int i = 0, n = validFields.size(); i < n; i++) {
Field field = validFields.get(i);
int accessIndex = -1;
if (access != null && useAsm.get(i) == 1) accessIndex = ((FieldAccess)access).getIndex(field.getName());
cachedFields.add(newCachedField(field, cachedFields.size(), accessIndex));
}
Collections.sort(cachedFields, this);