Fix passing reflection tests with fast global analysis enabled

This commit is contained in:
Alexey Andreev 2020-01-23 18:58:18 +03:00
parent c53a563e96
commit 72275a0877

View File

@ -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<String> getAccessibleFields(ReflectionContext context, String className) {
ClassReader cls = context.getClassSource().get(className);
if (cls == null) {
return Collections.emptyList();
}
Set<String> 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<MethodDescriptor> getAccessibleMethods(ReflectionContext context, String className) {
ClassReader cls = context.getClassSource().get(className);
if (cls == null) {
return Collections.emptyList();
}
Set<MethodDescriptor> methods = new HashSet<>();
for (MethodReader method : cls.getMethods()) {
if (method.getAnnotations().get(Reflectable.class.getName()) != null) {