Fix potential NPE in MethodAnalyzer

This commit is contained in:
Ben Gruver 2014-07-19 20:26:27 -07:00 committed by Connor Tumbleson
parent 1b0a917a6a
commit 5388ed57ba

View File

@ -1645,11 +1645,14 @@ public class MethodAnalyzer {
// methodClass is now the first accessible class found. Now. we need to make sure that the method is // methodClass is now the first accessible class found. Now. we need to make sure that the method is
// actually valid for this class // actually valid for this class
resolvedMethod = classPath.getClass(methodClass.getType()).getMethodByVtableIndex(methodIndex); MethodReference newResolvedMethod =
if (resolvedMethod == null) { classPath.getClass(methodClass.getType()).getMethodByVtableIndex(methodIndex);
if (newResolvedMethod == null) {
// TODO: fix NPE here
throw new ExceptionWithContext("Couldn't find accessible class while resolving method %s", throw new ExceptionWithContext("Couldn't find accessible class while resolving method %s",
ReferenceUtil.getMethodDescriptor(resolvedMethod, true)); ReferenceUtil.getMethodDescriptor(resolvedMethod, true));
} }
resolvedMethod = newResolvedMethod;
resolvedMethod = new ImmutableMethodReference(methodClass.getType(), resolvedMethod.getName(), resolvedMethod = new ImmutableMethodReference(methodClass.getType(), resolvedMethod.getName(),
resolvedMethod.getParameterTypes(), resolvedMethod.getReturnType()); resolvedMethod.getParameterTypes(), resolvedMethod.getReturnType());
} }