mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
JIRA #334 - check for null classreader
This commit is contained in:
parent
d9c5b3fd04
commit
744eb39e6d
|
@ -335,14 +335,19 @@ public class ReflectClassImpl<T> implements ReflectClass<T> {
|
||||||
@Override
|
@Override
|
||||||
public ReflectField[] getFields() {
|
public ReflectField[] getFields() {
|
||||||
if (fieldsCache == null) {
|
if (fieldsCache == null) {
|
||||||
Set<String> visited = new HashSet<>();
|
resolve();
|
||||||
fieldsCache = context.getClassSource()
|
if (classReader == null) {
|
||||||
.getAncestors(classReader.getName())
|
fieldsCache = new ReflectField[0];
|
||||||
.flatMap(cls -> cls.getFields().stream().filter(fld -> fld.getLevel() == AccessLevel.PUBLIC))
|
} else {
|
||||||
.filter(fld -> visited.add(fld.getName()))
|
Set<String> visited = new HashSet<>();
|
||||||
.map(fld -> context.getClass(ValueType.object(fld.getOwnerName()))
|
fieldsCache = context
|
||||||
.getDeclaredField(fld.getName()))
|
.getClassSource()
|
||||||
.toArray(ReflectField[]::new);
|
.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()))
|
||||||
|
.toArray(ReflectField[]::new);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fieldsCache.clone();
|
return fieldsCache.clone();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user