Program: 175914
Project: 175914
Buggy source:
/** 
 * Fills given class filled with values dictated by the strategy
 * @param < T > The type for which should be populated
 * @param pojo An instance to be filled with dummy values
 * @param annotations a list of annotations attached to this POJO defined elsewhere 
 * @param manufacturingCtx the manufacturing context
 * @param typeArgsMap a map relating the generic class arguments ("&lt;T, V&gt;" for example) with their actual types
 * @param genericTypeArgs The generic type arguments for the current generic class instance
 * @return An instance of &lt;T&gt; filled with dummy values
 * @throws InstantiationException If an exception occurred during instantiation
 * @throws IllegalAccessException If security was violated while creating the object
 * @throws InvocationTargetException If an exception occurred while invoking the constructor or factory method
 * @throws ClassNotFoundException If manufactured class cannot be loaded
 */
private <T>T populatePojoInternal(T pojo,List<Annotation> annotations,ManufacturingContext manufacturingCtx,Map<String,Type> typeArgsMap,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Class<?> pojoClass=pojo.getClass();
  if (pojo instanceof Collection && ((Collection<?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Collection<Object> collection=(Collection<Object>)pojo;
    AtomicReference<Type[]> elementGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
    Class<?> elementTypeClass=findInheretedCollectionElementType(collection,manufacturingCtx,elementGenericTypeArgs,typeArgsMap,genericTypeArgs);
    if (null == annotations) {
      annotations=new ArrayList<Annotation>();
    }
    for (    Annotation annotation : collection.getClass().getAnnotations()) {
      annotations.add(annotation);
    }
    String attributeName=null;
    fillCollection(manufacturingCtx,annotations,attributeName,collection,elementTypeClass,elementGenericTypeArgs.get());
  }
 else   if (pojo instanceof Map && ((Map<?,?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Map<Object,Object> map=(Map<Object,Object>)pojo;
    MapArguments mapArguments=findInheretedMapElementType(map,manufacturingCtx,typeArgsMap,genericTypeArgs);
    if (null != annotations) {
      mapArguments.getAnnotations().addAll(annotations);
    }
    fillMap(mapArguments,manufacturingCtx);
  }
  Class<?>[] parameterTypes=null;
  Class<?> attributeType=null;
  ClassInfo classInfo=classInfoStrategy.getClassInfo(pojo.getClass());
  Set<ClassAttribute> classAttributes=classInfo.getClassAttributes();
  Object setterArg=null;
  Iterator<ClassAttribute> iter=classAttributes.iterator();
  while (iter.hasNext()) {
    ClassAttribute attribute=iter.next();
    Set<Method> setters=attribute.getSetters();
    if (setters.isEmpty()) {
      if (attribute.getGetters().isEmpty()) {
        iter.remove();
      }
      continue;
    }
 else {
      iter.remove();
    }
    Method setter=PodamUtils.selectLatestMethod(setters);
    parameterTypes=setter.getParameterTypes();
    if (parameterTypes.length != 1) {
      LOG.warn("String_Node_Str",setter);
      continue;
    }
    attributeType=parameterTypes[0];
    List<Annotation> pojoAttributeAnnotations=PodamUtils.getAttributeAnnotations(attribute.getAttribute(),setter);
    AttributeStrategy<?> attributeStrategy=TypeManufacturerUtil.findAttributeStrategy(strategy,pojoAttributeAnnotations,attributeType);
    if (null != attributeStrategy) {
      setterArg=TypeManufacturerUtil.returnAttributeDataStrategyValue(attributeType,attributeStrategy);
    }
 else {
      AtomicReference<Type[]> typeGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
      Type genericType=setter.getGenericParameterTypes()[0];
      final Type[] typeArguments;
      if (!(genericType instanceof GenericArrayType)) {
        attributeType=TypeManufacturerUtil.resolveGenericParameter(genericType,typeArgsMap,typeGenericTypeArgs);
        typeArguments=typeGenericTypeArgs.get();
      }
 else {
        typeArguments=PodamConstants.NO_TYPES;
      }
      for (int i=0; i < typeArguments.length; i++) {
        if (typeArguments[i] instanceof TypeVariable) {
          Class<?> resolvedType=TypeManufacturerUtil.resolveGenericParameter(typeArguments[i],typeArgsMap,typeGenericTypeArgs);
          if (!Collection.class.isAssignableFrom(resolvedType) && !Map.class.isAssignableFrom(resolvedType)) {
            typeArguments[i]=resolvedType;
          }
        }
      }
      setterArg=manufactureAttributeValue(pojo,manufacturingCtx,attributeType,genericType,pojoAttributeAnnotations,attribute.getName(),typeArgsMap,typeArguments);
    }
    try {
      setter.invoke(pojo,setterArg);
    }
 catch (    IllegalAccessException e) {
      LOG.warn("String_Node_Str" + "String_Node_Str" + "String_Node_Str",setter.toString());
      setter.setAccessible(true);
      setter.invoke(pojo,setterArg);
    }
  }
  for (  ClassAttribute readOnlyAttribute : classAttributes) {
    Method getter=PodamUtils.selectLatestMethod(readOnlyAttribute.getGetters());
    if (getter != null && !getter.getReturnType().isPrimitive()) {
      if (getter.getGenericParameterTypes().length == 0) {
        Object fieldValue=null;
        try {
          fieldValue=getter.invoke(pojo,PodamConstants.NO_ARGS);
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str",getter);
        }
        if (fieldValue != null) {
          LOG.debug("String_Node_Str",getter);
          Type[] genericTypeArgsAll;
          Map<String,Type> paramTypeArgsMap;
          if (getter.getGenericReturnType() instanceof ParameterizedType) {
            paramTypeArgsMap=new HashMap<String,Type>(typeArgsMap);
            ParameterizedType paramType=(ParameterizedType)getter.getGenericReturnType();
            Type[] actualTypes=paramType.getActualTypeArguments();
            TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),actualTypes);
            genericTypeArgsAll=TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),genericTypeArgs);
          }
 else {
            paramTypeArgsMap=typeArgsMap;
            genericTypeArgsAll=genericTypeArgs;
          }
          List<Annotation> pojoAttributeAnnotations=PodamUtils.getAttributeAnnotations(readOnlyAttribute.getAttribute(),getter);
          Class<?> fieldClass=fieldValue.getClass();
          Integer depth=manufacturingCtx.getPojos().get(fieldClass);
          if (depth == null) {
            depth=-1;
          }
          if (depth <= strategy.getMaxDepth(fieldClass)) {
            manufacturingCtx.getPojos().put(fieldClass,depth + 1);
            populatePojoInternal(fieldValue,pojoAttributeAnnotations,manufacturingCtx,paramTypeArgsMap,genericTypeArgsAll);
            manufacturingCtx.getPojos().put(fieldClass,depth);
          }
 else {
            LOG.warn("String_Node_Str",getter);
          }
        }
      }
 else {
        LOG.warn("String_Node_Str",getter);
      }
    }
  }
  Collection<Method> extraMethods=classInfoStrategy.getExtraMethods(pojoClass);
  if (null != extraMethods) {
    for (    Method extraMethod : extraMethods) {
      Object[] args=getParameterValuesForMethod(extraMethod,pojoClass,manufacturingCtx,typeArgsMap,genericTypeArgs);
      extraMethod.invoke(pojo,args);
    }
  }
  return pojo;
}

Fixed version (ground truth):
/** 
 * Fills given class filled with values dictated by the strategy
 * @param < T > The type for which should be populated
 * @param pojo An instance to be filled with dummy values
 * @param annotations a list of annotations attached to this POJO defined elsewhere 
 * @param manufacturingCtx the manufacturing context
 * @param typeArgsMap a map relating the generic class arguments ("&lt;T, V&gt;" for example) with their actual types
 * @param genericTypeArgs The generic type arguments for the current generic class instance
 * @return An instance of &lt;T&gt; filled with dummy values
 * @throws InstantiationException If an exception occurred during instantiation
 * @throws IllegalAccessException If security was violated while creating the object
 * @throws InvocationTargetException If an exception occurred while invoking the constructor or factory method
 * @throws ClassNotFoundException If manufactured class cannot be loaded
 */
private <T>T populatePojoInternal(T pojo,List<Annotation> annotations,ManufacturingContext manufacturingCtx,Map<String,Type> typeArgsMap,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Class<?> pojoClass=pojo.getClass();
  if (pojoClass.isArray()) {
    if (null == annotations) {
      annotations=new ArrayList<Annotation>();
    }
    String attributeName=null;
    fillArray(pojo,attributeName,pojoClass.getClass().getComponentType(),pojoClass.getClass().getComponentType(),annotations,manufacturingCtx,typeArgsMap);
  }
  if (pojo instanceof Collection && ((Collection<?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Collection<Object> collection=(Collection<Object>)pojo;
    AtomicReference<Type[]> elementGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
    Class<?> elementTypeClass=findInheretedCollectionElementType(collection,manufacturingCtx,elementGenericTypeArgs,typeArgsMap,genericTypeArgs);
    if (null == annotations) {
      annotations=new ArrayList<Annotation>();
    }
    for (    Annotation annotation : collection.getClass().getAnnotations()) {
      annotations.add(annotation);
    }
    String attributeName=null;
    fillCollection(manufacturingCtx,annotations,attributeName,collection,elementTypeClass,elementGenericTypeArgs.get());
  }
 else   if (pojo instanceof Map && ((Map<?,?>)pojo).isEmpty()) {
    @SuppressWarnings("String_Node_Str") Map<Object,Object> map=(Map<Object,Object>)pojo;
    MapArguments mapArguments=findInheretedMapElementType(map,manufacturingCtx,typeArgsMap,genericTypeArgs);
    if (null != annotations) {
      mapArguments.getAnnotations().addAll(annotations);
    }
    fillMap(mapArguments,manufacturingCtx);
  }
  Class<?>[] parameterTypes=null;
  Class<?> attributeType=null;
  ClassInfo classInfo=classInfoStrategy.getClassInfo(pojo.getClass());
  Set<ClassAttribute> classAttributes=classInfo.getClassAttributes();
  Object setterArg=null;
  Iterator<ClassAttribute> iter=classAttributes.iterator();
  while (iter.hasNext()) {
    ClassAttribute attribute=iter.next();
    Set<Method> setters=attribute.getSetters();
    if (setters.isEmpty()) {
      if (attribute.getGetters().isEmpty()) {
        iter.remove();
      }
      continue;
    }
 else {
      iter.remove();
    }
    Method setter=PodamUtils.selectLatestMethod(setters);
    parameterTypes=setter.getParameterTypes();
    if (parameterTypes.length != 1) {
      LOG.warn("String_Node_Str",setter);
      continue;
    }
    attributeType=parameterTypes[0];
    List<Annotation> pojoAttributeAnnotations=PodamUtils.getAttributeAnnotations(attribute.getAttribute(),setter);
    AttributeStrategy<?> attributeStrategy=TypeManufacturerUtil.findAttributeStrategy(strategy,pojoAttributeAnnotations,attributeType);
    if (null != attributeStrategy) {
      setterArg=TypeManufacturerUtil.returnAttributeDataStrategyValue(attributeType,attributeStrategy);
    }
 else {
      AtomicReference<Type[]> typeGenericTypeArgs=new AtomicReference<Type[]>(PodamConstants.NO_TYPES);
      Type genericType=setter.getGenericParameterTypes()[0];
      final Type[] typeArguments;
      if (!(genericType instanceof GenericArrayType)) {
        attributeType=TypeManufacturerUtil.resolveGenericParameter(genericType,typeArgsMap,typeGenericTypeArgs);
        typeArguments=typeGenericTypeArgs.get();
      }
 else {
        typeArguments=PodamConstants.NO_TYPES;
      }
      for (int i=0; i < typeArguments.length; i++) {
        if (typeArguments[i] instanceof TypeVariable) {
          Class<?> resolvedType=TypeManufacturerUtil.resolveGenericParameter(typeArguments[i],typeArgsMap,typeGenericTypeArgs);
          if (!Collection.class.isAssignableFrom(resolvedType) && !Map.class.isAssignableFrom(resolvedType)) {
            typeArguments[i]=resolvedType;
          }
        }
      }
      setterArg=manufactureAttributeValue(pojo,manufacturingCtx,attributeType,genericType,pojoAttributeAnnotations,attribute.getName(),typeArgsMap,typeArguments);
    }
    try {
      setter.invoke(pojo,setterArg);
    }
 catch (    IllegalAccessException e) {
      LOG.warn("String_Node_Str" + "String_Node_Str" + "String_Node_Str",setter.toString());
      setter.setAccessible(true);
      setter.invoke(pojo,setterArg);
    }
  }
  for (  ClassAttribute readOnlyAttribute : classAttributes) {
    Method getter=PodamUtils.selectLatestMethod(readOnlyAttribute.getGetters());
    if (getter != null && !getter.getReturnType().isPrimitive()) {
      if (getter.getGenericParameterTypes().length == 0) {
        Object fieldValue=null;
        try {
          fieldValue=getter.invoke(pojo,PodamConstants.NO_ARGS);
        }
 catch (        Exception e) {
          LOG.debug("String_Node_Str",getter);
        }
        if (fieldValue != null) {
          LOG.debug("String_Node_Str",getter);
          Type[] genericTypeArgsAll;
          Map<String,Type> paramTypeArgsMap;
          if (getter.getGenericReturnType() instanceof ParameterizedType) {
            paramTypeArgsMap=new HashMap<String,Type>(typeArgsMap);
            ParameterizedType paramType=(ParameterizedType)getter.getGenericReturnType();
            Type[] actualTypes=paramType.getActualTypeArguments();
            TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),actualTypes);
            genericTypeArgsAll=TypeManufacturerUtil.fillTypeArgMap(paramTypeArgsMap,getter.getReturnType(),genericTypeArgs);
          }
 else {
            paramTypeArgsMap=typeArgsMap;
            genericTypeArgsAll=genericTypeArgs;
          }
          List<Annotation> pojoAttributeAnnotations=PodamUtils.getAttributeAnnotations(readOnlyAttribute.getAttribute(),getter);
          Class<?> fieldClass=fieldValue.getClass();
          Integer depth=manufacturingCtx.getPojos().get(fieldClass);
          if (depth == null) {
            depth=-1;
          }
          if (depth <= strategy.getMaxDepth(fieldClass)) {
            manufacturingCtx.getPojos().put(fieldClass,depth + 1);
            populatePojoInternal(fieldValue,pojoAttributeAnnotations,manufacturingCtx,paramTypeArgsMap,genericTypeArgsAll);
            manufacturingCtx.getPojos().put(fieldClass,depth);
          }
 else {
            LOG.warn("String_Node_Str",getter);
          }
        }
      }
 else {
        LOG.warn("String_Node_Str",getter);
      }
    }
  }
  Collection<Method> extraMethods=classInfoStrategy.getExtraMethods(pojoClass);
  if (null != extraMethods) {
    for (    Method extraMethod : extraMethods) {
      Object[] args=getParameterValuesForMethod(extraMethod,pojoClass,manufacturingCtx,typeArgsMap,genericTypeArgs);
      extraMethod.invoke(pojo,args);
    }
  }
  return pojo;
}