/**
* Finds the most specific common super class of the given classes.
* This method is a copy from org.jboss.forge.furnace.proxy.javassist.bytecode.analysis.Type.
*/
public static CtClass commonSuperClass(CtClass one, CtClass two) throws NotFoundException {
CtClass deep = one;
CtClass shallow = two;
CtClass backupShallow = shallow;
CtClass backupDeep = deep;
// Phase 1 - Find the deepest hierarchy, set deep and shallow correctly
for (;;) {
// In case we get lucky, and find a match early
if (eq(deep, shallow) && deep.getSuperclass() != null)
return deep;
CtClass deepSuper = deep.getSuperclass();
CtClass shallowSuper = shallow.getSuperclass();
if (shallowSuper == null) {
// right, now reset shallow
shallow = backupShallow;
break;