JIRA - check for null classreader
@@ -335,15 +335,20 @@ public class ReflectClassImpl<T> implements ReflectClass<T> {
@Override
public ReflectField[] getFields() {
if (fieldsCache == null) {
+ resolve();
+ if (classReader == null) {
+ fieldsCache = new ReflectField[0];
+ } else {
Set<String> visited = new HashSet<>();
- fieldsCache = context.getClassSource()
+ fieldsCache = context
+ .getClassSource()
.getAncestors(classReader.getName())
.flatMap(cls -> cls.getFields().stream().filter(fld -> fld.getLevel() == AccessLevel.PUBLIC))
.filter(fld -> visited.add(fld.getName()))
- .map(fld -> context.getClass(ValueType.object(fld.getOwnerName()))
- .getDeclaredField(fld.getName()))
+ .map(fld -> context.getClass(ValueType.object(fld.getOwnerName())).getDeclaredField(fld.getName()))
.toArray(ReflectField[]::new);
}
+ }
return fieldsCache.clone();
}
