public static CtClass commonSuperClass(CtClass one,CtClass two) throws NotFoundException {
  CtClass deep=one;
  CtClass shallow=two;
  CtClass backupShallow=shallow;
  CtClass backupDeep=deep;
  for (; ; ) {
    if (eq(deep,shallow) && deep.getSuperclass() != null)     return deep;
    CtClass deepSuper=deep.getSuperclass();
    CtClass shallowSuper=shallow.getSuperclass();
    if (shallowSuper == null) {
      shallow=backupShallow;
      break;
    }
    if (deepSuper == null) {
      deep=backupDeep;
      backupDeep=backupShallow;
      backupShallow=deep;
      deep=shallow;
      shallow=backupShallow;
      break;
    }
    deep=deepSuper;
    shallow=shallowSuper;
  }
  for (; ; ) {
    deep=deep.getSuperclass();
    if (deep == null)     break;
    backupDeep=backupDeep.getSuperclass();
  }
  deep=backupDeep;
  while (!eq(deep,shallow)) {
    deep=deep.getSuperclass();
    shallow=shallow.getSuperclass();
  }
  return deep;
}

public static CtClass commonSuperClass ( CtClass one , CtClass two ) throws NotFoundException { CtClass deep = one ; CtClass shallow = two ; CtClass backupShallow = shallow ; CtClass backupDeep = deep ; for ( ; ; ) { if ( eq ( deep , shallow ) && deep . getSuperclass ( ) != null ) return deep ; CtClass deepSuper = deep . getSuperclass ( ) ; CtClass shallowSuper = shallow . getSuperclass ( ) ; if ( shallowSuper == null ) { shallow = backupShallow ; break ; } if ( deepSuper == null ) { deep = backupDeep ; backupDeep = backupShallow ; backupShallow = deep ; deep = shallow ; shallow = backupShallow ; break ; } deep = deepSuper ; shallow = shallowSuper ; } for ( ; ; ) { deep = deep . getSuperclass ( ) ; if ( deep == null ) break ; backupDeep = backupDeep . getSuperclass ( ) ; } deep = backupDeep ; while ( ! eq ( deep , shallow ) ) { deep = deep . getSuperclass ( ) ; shallow = shallow . getSuperclass ( ) ; } return deep ; }
finds the most specific common super class of the given classes . this method is a copy from javassist . bytecode . analysis . type .
