diff --git a/tests/src/test/java/org/teavm/classlib/support/ReflectionSupplierImpl.java b/tests/src/test/java/org/teavm/classlib/support/ReflectionSupplierImpl.java index 8f4c59886..312cf41e8 100644 --- a/tests/src/test/java/org/teavm/classlib/support/ReflectionSupplierImpl.java +++ b/tests/src/test/java/org/teavm/classlib/support/ReflectionSupplierImpl.java @@ -17,6 +17,7 @@ package org.teavm.classlib.support; import java.lang.invoke.SerializedLambda; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.Set; import org.teavm.classlib.ReflectionContext; @@ -30,6 +31,9 @@ public class ReflectionSupplierImpl implements ReflectionSupplier { @Override public Collection getAccessibleFields(ReflectionContext context, String className) { ClassReader cls = context.getClassSource().get(className); + if (cls == null) { + return Collections.emptyList(); + } Set fields = new HashSet<>(); for (FieldReader field : cls.getFields()) { if (field.getAnnotations().get(Reflectable.class.getName()) != null) { @@ -42,6 +46,9 @@ public class ReflectionSupplierImpl implements ReflectionSupplier { @Override public Collection getAccessibleMethods(ReflectionContext context, String className) { ClassReader cls = context.getClassSource().get(className); + if (cls == null) { + return Collections.emptyList(); + } Set methods = new HashSet<>(); for (MethodReader method : cls.getMethods()) { if (method.getAnnotations().get(Reflectable.class.getName()) != null) {