From cdffb779e0e8ee9ec5028cc81336a76961c3473b Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 18 Jun 2018 13:40:00 +0300 Subject: [PATCH] Fix NPE when there are build errors related to lack of reflection support --- .../impl/ReflectionDependencyListener.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/impl/ReflectionDependencyListener.java b/classlib/src/main/java/org/teavm/classlib/impl/ReflectionDependencyListener.java index 8a253c4aa..3211576bb 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/ReflectionDependencyListener.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/ReflectionDependencyListener.java @@ -113,8 +113,10 @@ public class ReflectionDependencyListener extends AbstractDependencyListener { classesWithReflectableFields.add(type.getName()); ClassReader cls = agent.getClassSource().get(type.getName()); - for (FieldReader field : cls.getFields()) { - linkType(agent, field.getType()); + if (cls != null) { + for (FieldReader field : cls.getFields()) { + linkType(agent, field.getType()); + } } } }); @@ -124,10 +126,12 @@ public class ReflectionDependencyListener extends AbstractDependencyListener { classesWithReflectableMethods.add(type.getName()); ClassReader cls = agent.getClassSource().get(type.getName()); - for (MethodReader reflectableMethod : cls.getMethods()) { - linkType(agent, reflectableMethod.getResultType()); - for (ValueType param : reflectableMethod.getParameterTypes()) { - linkType(agent, param); + if (cls != null) { + for (MethodReader reflectableMethod : cls.getMethods()) { + linkType(agent, reflectableMethod.getResultType()); + for (ValueType param : reflectableMethod.getParameterTypes()) { + linkType(agent, param); + } } } }