Fix issue with how the set of interfaces a class implements is calculated

This commit is contained in:
Ben Gruver 2013-04-08 23:08:02 -07:00
parent 541b934948
commit a0c24f1c9f

View File

@ -865,6 +865,14 @@ public class ClassPath {
} }
} }
private static void addInterfaceToSet(Set<ClassDef> interfaces, ClassDef iface) {
if (interfaces.add(iface)) {
for (ClassDef subiface: iface.implementedInterfaces) {
addInterfaceToSet(interfaces, subiface);
}
}
}
private TreeSet<ClassDef> loadAllImplementedInterfaces(UnresolvedClassInfo classInfo) { private TreeSet<ClassDef> loadAllImplementedInterfaces(UnresolvedClassInfo classInfo) {
assert classType != null; assert classType != null;
assert classType.equals("Ljava/lang/Object;") || superclass != null; assert classType.equals("Ljava/lang/Object;") || superclass != null;
@ -874,11 +882,10 @@ public class ClassPath {
if (superclass != null) { if (superclass != null) {
for (ClassDef interfaceDef: superclass.implementedInterfaces) { for (ClassDef interfaceDef: superclass.implementedInterfaces) {
implementedInterfaceSet.add(interfaceDef); addInterfaceToSet(implementedInterfaceSet, interfaceDef);
} }
} }
if (classInfo.interfaces != null) { if (classInfo.interfaces != null) {
for (String interfaceType: classInfo.interfaces) { for (String interfaceType: classInfo.interfaces) {
ClassDef interfaceDef; ClassDef interfaceDef;
@ -889,14 +896,7 @@ public class ClassPath {
String.format("Could not find interface %s", interfaceType)); String.format("Could not find interface %s", interfaceType));
} }
assert interfaceDef.isInterface(); assert interfaceDef.isInterface();
implementedInterfaceSet.add(interfaceDef); addInterfaceToSet(implementedInterfaceSet, interfaceDef);
interfaceDef = interfaceDef.getSuperclass();
while (!interfaceDef.getClassType().equals("Ljava/lang/Object;")) {
assert interfaceDef.isInterface();
implementedInterfaceSet.add(interfaceDef);
interfaceDef = interfaceDef.getSuperclass();
}
} }
} }