Program: 75149
Project: 75149
Buggy source:
/** 
 * Compute the compatibility rating between this type and another formal type. If the result is larger than or equal to 0, the two types are compatible. An object of this type can be assigned to the given formal type only when the two types are compatible. <p> The compatibility rating is an integer number. When it is -1, the two types are not compatible. When it is 0, the two types are the same. When it is a natural number, it denotes how compatible the two types are. The smaller this natural number is, the more compatible this type is with the given formal type.
 * @param formalType The formal type to be evaluated.
 * @param loader The {@link ClassLoader} object to be used when theclasses of types are resolved. This functioon uses this loader to resolve both types if they are classes, and also their superclasses and the interfaces that they implement, if necessary.
 * @return The compatibility rating as an integer larger than or equal to-1.
 * @throws ClassNotFoundException Thrown when a class cannot be loaded.
 */
public int compatibility(Type formalType,ClassLoader loader) throws ClassNotFoundException {
  if (equals(formalType))   return 0;
  if (_primitiveNum == NULL_NUM && !formalType.isPrimitive())   return 0;
  if (isPrimitive() != formalType.isPrimitive())   return -1;
  if (isPrimitive())   if (formalType.isPrimitive())   if (_primitiveNum == CHAR_NUM)   if (formalType._primitiveNum == INT_NUM)   return 1;
 else   if (formalType._primitiveNum == LONG_NUM)   return 2;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 3;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 4;
 else   return -1;
 else   if (_primitiveNum == INT_NUM)   if (formalType._primitiveNum == LONG_NUM)   return 1;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 2;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 3;
 else   return -1;
 else   if (_primitiveNum == LONG_NUM)   if (formalType._primitiveNum == DOUBLE_NUM)   return 1;
 else   return -1;
 else   if (_primitiveNum == SHORT_NUM)   if (formalType._primitiveNum == INT_NUM)   return 1;
 else   if (formalType._primitiveNum == LONG_NUM)   return 2;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 3;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 4;
 else   return -1;
 else   if (_primitiveNum == BYTE_NUM)   if (formalType._primitiveNum == SHORT_NUM)   return 1;
 else   if (formalType._primitiveNum == INT_NUM)   return 2;
 else   if (formalType._primitiveNum == LONG_NUM)   return 3;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 4;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 5;
 else   return -1;
 else   if (_fullName.equals("String_Node_Str"))   if (formalType._fullName.equals("String_Node_Str"))   return 1;
 else   return -1;
 else   return -1;
 else   return -1;
 else {
    Type selfType=this;
    while (selfType.isArray() && formalType.isArray()) {
      selfType=selfType.removeOneDimension();
      formalType=formalType.removeOneDimension();
    }
    Class class1=selfType.toClass(loader);
    Class class2=formalType.toClass(loader);
    int i=0;
    while (class1 != null) {
      if (class1.getName().equals(class2.getName()))       return i;
      Class[] interfaces=class1.getInterfaces();
      for (int j=0; j < interfaces.length; j++) {
        Class superInterface=interfaces[j];
        Class[] superInterfaces=superInterface.getInterfaces();
        for (int k=0; k <= superInterfaces.length; k++) {
          Class currentInterface;
          if (k == 0)           currentInterface=superInterface;
 else           currentInterface=superInterfaces[k - 1];
          if (currentInterface.getName().equals(class2.getName()))           return i;
        }
      }
      i++;
      class1=class1.getSuperclass();
    }
    if (class2.getName().equals("String_Node_Str"))     return i;
 else     return -1;
  }
}

Fixed version (ground truth):
/** 
 * Compute the compatibility rating between this type and another formal type. If the result is larger than or equal to 0, the two types are compatible. An object of this type can be assigned to the given formal type only when the two types are compatible. <p> The compatibility rating is an integer number. When it is -1, the two types are not compatible. When it is 0, the two types are the same. When it is a natural number, it denotes how compatible the two types are. The smaller this natural number is, the more compatible this type is with the given formal type.
 * @param formalType The formal type to be evaluated.
 * @param loader The {@link ClassLoader} object to be used when theclasses of types are resolved. This functioon uses this loader to resolve both types if they are classes, and also their superclasses and the interfaces that they implement, if necessary.
 * @return The compatibility rating as an integer larger than or equal to-1.
 * @throws ClassNotFoundException Thrown when a class cannot be loaded.
 */
public int compatibility(Type formalType,ClassLoader loader) throws ClassNotFoundException {
  if (equals(formalType))   return 0;
  if (_primitiveNum == NULL_NUM && !formalType.isPrimitive())   return 0;
  if (isPrimitive() != formalType.isPrimitive())   return -1;
  if (isPrimitive())   if (formalType.isPrimitive())   if (_primitiveNum == CHAR_NUM)   if (formalType._primitiveNum == INT_NUM)   return 1;
 else   if (formalType._primitiveNum == LONG_NUM)   return 2;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 3;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 4;
 else   return -1;
 else   if (_primitiveNum == INT_NUM)   if (formalType._primitiveNum == LONG_NUM)   return 1;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 2;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 3;
 else   if (formalType._primitiveNum == BYTE_NUM)   return 4;
 else   if (formalType._primitiveNum == SHORT_NUM)   return 4;
 else   return -1;
 else   if (_primitiveNum == LONG_NUM)   if (formalType._primitiveNum == DOUBLE_NUM)   return 1;
 else   return -1;
 else   if (_primitiveNum == SHORT_NUM)   if (formalType._primitiveNum == INT_NUM)   return 1;
 else   if (formalType._primitiveNum == LONG_NUM)   return 2;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 3;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 4;
 else   return -1;
 else   if (_primitiveNum == BYTE_NUM)   if (formalType._primitiveNum == SHORT_NUM)   return 1;
 else   if (formalType._primitiveNum == INT_NUM)   return 2;
 else   if (formalType._primitiveNum == LONG_NUM)   return 3;
 else   if (formalType._primitiveNum == FLOAT_NUM)   return 4;
 else   if (formalType._primitiveNum == DOUBLE_NUM)   return 5;
 else   return -1;
 else   if (_fullName.equals("String_Node_Str"))   if (formalType._fullName.equals("String_Node_Str"))   return 1;
 else   return -1;
 else   return -1;
 else   return -1;
 else {
    Type selfType=this;
    while (selfType.isArray() && formalType.isArray()) {
      selfType=selfType.removeOneDimension();
      formalType=formalType.removeOneDimension();
    }
    Class class1=selfType.toClass(loader);
    Class class2=formalType.toClass(loader);
    int i=0;
    while (class1 != null) {
      List workList=new LinkedList();
      Set handledSet=new HashSet();
      workList.add(class1);
      while (!workList.isEmpty()) {
        Class c=(Class)workList.remove(0);
        if (c.getName().equals(class2.getName()))         return i;
        handledSet.add(c);
        Class[] interfaces=c.getInterfaces();
        for (int k=0; k < interfaces.length; k++)         if (!handledSet.contains(interfaces[k]))         workList.add(interfaces[k]);
      }
      i++;
      class1=class1.getSuperclass();
    }
    if (class2.getName().equals("String_Node_Str"))     return i;
 else     return -1;
  }
}