sandbox/src/main/java/org/robolectric/internal/bytecode/InstrumentingClassWriter.java
@Override
  protected String getCommonSuperClass(final String type1, final String type2) {
    try {
      ClassNode info1 = typeInfo(type1);
      ClassNode info2 = typeInfo(type2);
      if ((info1.access & Opcodes.ACC_INTERFACE) != 0) {
        if (typeImplements(type2, info2, type1)) {
          return type1;
        }
        if ((info2.access & Opcodes.ACC_INTERFACE) != 0) {
          if (typeImplements(type1, info1, type2)) {
            return type2;
          }
        }
        return "java/lang/Object";
      }
      if ((info2.access & Opcodes.ACC_INTERFACE) != 0) {
        if (typeImplements(type1, info1, type2)) {
          return type2;
        } else {
          return "java/lang/Object";
        }
      }
      String b1 = typeAncestors(type1, info1);
      String 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 (ClassNotFoundException e) {
      return "java/lang/Object"; // Handle classes that may be obfuscated
    }
  }
@Override
  protected String getCommonSuperClass(final String type1, final String type2) {
    try {
      ClassNode info1 = typeInfo(type1);
      ClassNode info2 = typeInfo(type2);
      if ((info1.access & Opcodes.ACC_INTERFACE) != 0) {
        if (typeImplements(type2, info2, type1)) {
          return type1;
        }
        if ((info2.access & Opcodes.ACC_INTERFACE) != 0) {
          if (typeImplements(type1, info1, type2)) {
            return type2;
          }
        }
        return "java/lang/Object";
      }
      if ((info2.access & Opcodes.ACC_INTERFACE) != 0) {
        if (typeImplements(type1, info1, type2)) {
          return type2;
        } else {
          return "java/lang/Object";
        }
      }
      String b1 = typeAncestors(type1, info1);
      String 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 (ClassNotFoundException e) {
      return "java/lang/Object"; // Handle classes that may be obfuscated
    }
  }
@ Override protected String getCommonSuperClass ( final String type1 , final String type2 ) { try { ClassNode info1 = typeInfo ( type1 ) ; ClassNode info2 = typeInfo ( type2 ) ; if ( ( info1 . access & Opcodes . ACC_INTERFACE ) != 0 ) { if ( typeImplements ( type2 , info2 , type1 ) ) { return type1 ; } if ( ( info2 . access & Opcodes . ACC_INTERFACE ) != 0 ) { if ( typeImplements ( type1 , info1 , type2 ) ) { return type2 ; } } return "java/lang/Object" ; } if ( ( info2 . access & Opcodes . ACC_INTERFACE ) != 0 ) { if ( typeImplements ( type1 , info1 , type2 ) ) { return type2 ; } else { return "java/lang/Object" ; } } String b1 = typeAncestors ( type1 , info1 ) ; String 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 ( ClassNotFoundException e ) { return "java/lang/Object" ; // Handle classes that may be obfuscated } }
Returns the common super type of the two given types without actually loading
the classes in the ClassLoader.
Returns the common super type of the two given types without actually loading the classes in the ClassLoader .