Program: 91177
Project: 91177
Buggy source:
private static SymbolType valueOfClass(Class<?> type,SymbolType arg,Map<String,SymbolType> updatedTypeMapping,Map<String,SymbolType> typeMapping) throws InvalidTypeException {
  SymbolType returnType;
  Class<?> aux=type;
  returnType=new SymbolType();
  int arrayCount=0;
  while (aux.isArray()) {
    arrayCount++;
    aux=aux.getComponentType();
  }
  returnType.setArrayCount(arrayCount);
  returnType.setName(aux.getName());
  Type[] typeParams=aux.getTypeParameters();
  if (typeParams.length > 0) {
    List<SymbolType> params=new LinkedList<SymbolType>();
    List<SymbolType> implParams=new LinkedList<SymbolType>();
    boolean isParameterizedImplementation=false;
    List<SymbolType> parameterizedTypes=null;
    Iterator<SymbolType> it=null;
    if (arg != null) {
      Class<?> argClass=arg.getClazz();
      parameterizedTypes=arg.getParameterizedTypes();
      if (parameterizedTypes != null) {
        it=parameterizedTypes.iterator();
      }
      List<Type> implementations=ClassInspector.getInterfaceOrSuperclassImplementations(argClass,aux);
      Iterator<Type> itTypes=implementations.iterator();
      Type[] typeParamsAux=typeParams;
      Map<String,SymbolType> auxMap=new HashMap<String,SymbolType>(typeMapping);
      while (itTypes.hasNext()) {
        Type implementation=itTypes.next();
        if (implementation instanceof ParameterizedType) {
          ParameterizedType ptype=(ParameterizedType)implementation;
          Map<String,SymbolType> typeMappingVars=arg.getTypeMappingVariables();
          Type[] targuments=ptype.getActualTypeArguments();
          for (int i=0; i < targuments.length; i++) {
            SymbolType st=null;
            if (targuments[i] instanceof TypeVariable) {
              String name=((TypeVariable<?>)targuments[i]).getName();
              if (typeMappingVars != null && typeMappingVars.containsKey(name)) {
                st=typeMappingVars.get(name);
              }
 else               if (it != null && it.hasNext()) {
                st=it.next();
              }
 else {
                st=new SymbolType(Object.class);
              }
            }
 else {
              st=SymbolType.valueOf(targuments[i],auxMap);
            }
            if (st != null) {
              implParams.add(st);
            }
          }
          isParameterizedImplementation=true;
          it=implParams.iterator();
          params=implParams;
          implParams=new LinkedList<SymbolType>();
          parameterizedTypes=params;
        }
 else         if (implementation instanceof Class<?>) {
          Class<?> auxClass=(Class<?>)implementation;
          boolean isRecursiveThenOmit=false;
          if (type instanceof Class<?>) {
            isRecursiveThenOmit=((Class<?>)type).getName().equals(auxClass.getName());
          }
          if (!isRecursiveThenOmit) {
            typeParamsAux=auxClass.getTypeParameters();
            loadTypeParams(it,typeParamsAux,parameterizedTypes,typeMapping,auxMap);
          }
        }
      }
    }
    if (!isParameterizedImplementation) {
      if (parameterizedTypes != null) {
        it=parameterizedTypes.iterator();
      }
      for (int i=0; i < typeParams.length; i++) {
        SymbolType ref=null;
        if (it != null && it.hasNext()) {
          ref=it.next();
        }
        boolean isRecursiveThenOmit=false;
        if (typeParams[i] instanceof TypeVariable) {
          TypeVariable<?> tv=(TypeVariable<?>)typeParams[i];
          Type[] types=tv.getBounds();
          if (types.length == 1) {
            if (types[0] instanceof Class<?> && type instanceof Class<?>) {
              isRecursiveThenOmit=((Class<?>)type).getName().equals(((Class<?>)types[0]).getName());
            }
          }
        }
        if (!isRecursiveThenOmit) {
          SymbolType tp=valueOf(typeParams[i],ref,updatedTypeMapping,typeMapping);
          if (tp != null) {
            params.add(tp);
          }
        }
 else {
          params.add(returnType);
        }
      }
    }
    if (!params.isEmpty()) {
      returnType.setParameterizedTypes(params);
    }
  }
  return returnType;
}

Fixed version (ground truth):
private static SymbolType valueOfClass(Class<?> type,SymbolType arg,Map<String,SymbolType> updatedTypeMapping,Map<String,SymbolType> typeMapping) throws InvalidTypeException {
  SymbolType returnType;
  Class<?> aux=type;
  returnType=new SymbolType();
  int arrayCount=0;
  while (aux.isArray()) {
    arrayCount++;
    aux=aux.getComponentType();
  }
  returnType.setArrayCount(arrayCount);
  returnType.setName(aux.getName());
  Type[] typeParams=aux.getTypeParameters();
  if (typeParams.length > 0) {
    List<SymbolType> params=new LinkedList<SymbolType>();
    List<SymbolType> implParams=new LinkedList<SymbolType>();
    boolean isParameterizedImplementation=false;
    List<SymbolType> parameterizedTypes=null;
    Iterator<SymbolType> it=null;
    if (arg != null) {
      Class<?> argClass=arg.getClazz();
      parameterizedTypes=arg.getParameterizedTypes();
      if (parameterizedTypes != null) {
        it=parameterizedTypes.iterator();
      }
      List<Type> implementations=ClassInspector.getInterfaceOrSuperclassImplementations(argClass,aux);
      Iterator<Type> itTypes=implementations.iterator();
      Type[] typeParamsAux=typeParams;
      Map<String,SymbolType> auxMap=new HashMap<String,SymbolType>(typeMapping);
      while (itTypes.hasNext()) {
        Type implementation=itTypes.next();
        if (implementation instanceof ParameterizedType) {
          ParameterizedType ptype=(ParameterizedType)implementation;
          Map<String,SymbolType> typeMappingVars=arg.getTypeMappingVariables();
          Type[] targuments=ptype.getActualTypeArguments();
          for (int i=0; i < targuments.length; i++) {
            SymbolType st=null;
            if (targuments[i] instanceof TypeVariable) {
              String name=((TypeVariable<?>)targuments[i]).getName();
              if (typeMappingVars != null && typeMappingVars.containsKey(name)) {
                st=typeMappingVars.get(name);
              }
 else               if (it != null && it.hasNext()) {
                st=it.next();
              }
 else {
                st=new SymbolType(Object.class);
              }
            }
 else {
              st=SymbolType.valueOf(targuments[i],auxMap);
            }
            if (st != null) {
              implParams.add(st);
            }
          }
          isParameterizedImplementation=true;
          it=implParams.iterator();
          params=implParams;
          implParams=new LinkedList<SymbolType>();
          parameterizedTypes=params;
        }
 else         if (implementation instanceof Class<?>) {
          Class<?> auxClass=(Class<?>)implementation;
          boolean isRecursiveThenOmit=false;
          if (type instanceof Class<?>) {
            isRecursiveThenOmit=((Class<?>)type).getName().equals(auxClass.getName());
          }
          if (!isRecursiveThenOmit) {
            typeParamsAux=auxClass.getTypeParameters();
            loadTypeParams(it,typeParamsAux,parameterizedTypes,typeMapping,auxMap);
          }
        }
      }
    }
    if (!isParameterizedImplementation) {
      if (parameterizedTypes != null) {
        it=parameterizedTypes.iterator();
      }
      for (int i=0; i < typeParams.length; i++) {
        SymbolType ref=null;
        if (it != null && it.hasNext()) {
          ref=it.next();
        }
        boolean isRecursiveThenOmit=false;
        if (typeParams[i] instanceof TypeVariable) {
          TypeVariable<?> tv=(TypeVariable<?>)typeParams[i];
          Type[] types=tv.getBounds();
          if (types.length == 1) {
            if (types[0] instanceof Class<?> && type instanceof Class<?>) {
              isRecursiveThenOmit=((Class<?>)type).getName().equals(((Class<?>)types[0]).getName());
            }
          }
        }
        if (!isRecursiveThenOmit) {
          SymbolType tp=valueOf(typeParams[i],ref,updatedTypeMapping,typeMapping);
          if (arg != null || !Object.class.getName().equals(tp.getName())) {
            if (tp != null) {
              params.add(tp);
            }
          }
        }
 else {
          params.add(returnType);
        }
      }
    }
    if (!params.isEmpty()) {
      returnType.setParameterizedTypes(params);
    }
  }
  return returnType;
}