in xstream/src/java/com/thoughtworks/xstream/converters/reflection/AbstractAttributedCharacterIteratorAttributeConverter.java [101:135]
private Map<String, T> buildAttributeMap(Class<? extends T> type) {
final Map<String, T> attributeMap = new HashMap<>();
final Field instanceMap = Fields.locate(type, Map.class, true);
if (instanceMap != null) {
try {
@SuppressWarnings("unchecked")
final Map<String, T> map = (Map<String, T>)Fields.read(instanceMap, null);
if (map != null) {
boolean valid = true;
for (final Map.Entry<String, T> entry : map.entrySet()) {
valid = entry.getKey().getClass() == String.class && entry.getValue().getClass() == type;
}
if (valid) {
attributeMap.putAll(map);
}
}
} catch (final ObjectAccessException e) {
}
}
if (attributeMap.isEmpty()) {
try {
final Field[] fields = type.getDeclaredFields();
for (final Field field : fields) {
if (field.getType() == type == Modifier.isStatic(field.getModifiers())) {
@SuppressWarnings("unchecked")
final T attribute = (T)Fields.read(field, null);
attributeMap.put(toString(attribute), attribute);
}
}
} catch (final SecurityException | ObjectAccessException | NoClassDefFoundError e) {
attributeMap.clear();
}
}
return attributeMap;
}