when searching for some method in hierarchy, should also search in interfaces (correctly fix IDEA-101410)

This commit is contained in:
Eugene Zhuravlev
2013-02-19 22:39:17 +01:00
parent 9c1b0aa596
commit c2797bef41
@@ -250,15 +250,36 @@ public class InstrumentationClassFinder {
return null;
}
public PseudoMethod findMethodInHierarchy(String name, String descriptor) throws IOException, ClassNotFoundException {
PseudoMethod method = findMethod(name, descriptor);
if (method == null) {
PseudoClass superClass = getSuperClass();
if (superClass != null) {
method = superClass.findMethodInHierarchy(name, descriptor);
public PseudoMethod findMethodInHierarchy(final String name, final String descriptor) throws IOException, ClassNotFoundException {
// first find in superclasses
for (PseudoClass c = this; c != null; c = c.getSuperClass()) {
final PseudoMethod method = c.findMethod(name, descriptor);
if (method != null) {
return method;
}
}
return method;
// second, check interfaces
for (PseudoClass iface : getInterfaces()) {
final PseudoMethod method = findInterfaceMethodRecursively(iface, name, descriptor);
if (method != null) {
return method;
}
}
return null;
}
private static PseudoMethod findInterfaceMethodRecursively(PseudoClass fromIface, final String name, final String descriptor) throws IOException, ClassNotFoundException {
PseudoMethod method = fromIface.findMethod(name, descriptor);
if (method != null) {
return method;
}
for (PseudoClass superIface : fromIface.getInterfaces()) {
method = findInterfaceMethodRecursively(superIface, name, descriptor);
if (method != null) {
return method;
}
}
return null;
}
public InstrumentationClassFinder getFinder() {