protected String getCommonSuperClass()

in util/src/com/intellij/rt/coverage/instrumentation/ClassWriterImpl.java [46:87]


  protected String getCommonSuperClass(String type1, String type2) {
    try {
      ClassReader info1 = getOrLoadClassReader(type1);
      ClassReader info2 = getOrLoadClassReader(type2);
      String
          superType = checkImplementInterface(type1, type2, info1, info2);
      if (superType != null) return superType;
      superType = checkImplementInterface(type2, type1, info2, info1);
      if (superType != null) return superType;

      StringBuilder b1 = typeAncestors(type1, info1);
      StringBuilder b2 = typeAncestors(type2, info2);
      String result = JAVA_LANG_OBJECT;
      int end1 = b1.length();
      int end2 = b2.length();
      while (true) {
        int start1 = b1.lastIndexOf(";", end1 - 1);
        int start2 = b2.lastIndexOf(";", end2 - 1);
        if (start1 != -1 && start2 != -1 && end1 - start1 == end2 - start2) {
          String p1 = b1.substring(start1 + 1, end1);
          String p2 = b2.substring(start2 + 1, end2);
          if (p1.equals(p2)) {
            result = p1;
            end1 = start1;
            end2 = start2;
          } else {
            return result;
          }
        } else {
          return result;
        }
      }
    } catch (FrameComputationClassNotFoundException e) {
      try {
        return super.getCommonSuperClass(type1, type2);
      } catch (TypeNotPresentException ignored) {
        throw e;
      }
    } catch (IOException e) {
      throw new RuntimeException(e.toString());
    }
  }