David_W (70) [Avatar] Offline
#1
Because of the way that it is called, it won't cause a problem, but the 2 ors in the while loops below should be ands.

private static Class findCommonAncestor(Class one, Class two) throws IllegalArgumentException {
Class ancestor = one;
while (ancestor != Object.class || ancestor != null) {
if (ancestor.isAssignableFrom(two)) {
return ancestor;
}
ancestor = ancestor.getSuperclass();
}
// try the other class hierarchy
ancestor = two;
while (ancestor != Object.class || ancestor != null) {
if (ancestor.isAssignableFrom(one)) {
return ancestor;
}
ancestor = ancestor.getSuperclass();
}
return null;
}