Program: 177947
Project: 177947
Buggy source:
/** 
 * It attempts to create an instance of the given class <p> This method attempts to create an instance of the given argument for classes without setters. These may be either immutable classes (e.g. with final attributes and no setters) or Java classes (e.g. belonging to the java / javax namespace). In case the class does not provide a public, no-arg constructor (e.g. Calendar), this method attempts to find a , no-args, factory method (e.g. getInstance()) and it invokes it </p>
 * @param pojoClass The name of the class for which an instance filled with values is required
 * @param pojos Set of manufactured pojos' types
 * @param genericTypeArgs The generic type arguments for the current generic class instance
 * @return An instance of the given class
 * @throws IllegalArgumentException If an illegal argument was passed to the constructor
 * @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 it was not possible to create a class from a string
 */
private Object instantiatePojoWithoutConstructors(Class<?> pojoClass,Map<Class<?>,Integer> pojos,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Object retValue=null;
  final Map<String,Type> typeArgsMap=new HashMap<String,Type>();
  Type[] genericTypeArgsExtra=fillTypeArgMap(typeArgsMap,pojoClass,genericTypeArgs);
  Method[] declaredMethods=pojoClass.getDeclaredMethods();
  strategy.sort(declaredMethods);
  Object[] parameterValues=null;
  Object[] noParams=new Object[]{};
  for (  Method candidateConstructor : declaredMethods) {
    if (!Modifier.isStatic(candidateConstructor.getModifiers()) || !candidateConstructor.getReturnType().equals(pojoClass) || retValue != null) {
      continue;
    }
    parameterValues=new Object[candidateConstructor.getParameterTypes().length];
    Class<?>[] parameterTypes=candidateConstructor.getParameterTypes();
    if (parameterTypes.length == 0) {
      parameterValues=noParams;
    }
 else {
      Annotation[][] parameterAnnotations=candidateConstructor.getParameterAnnotations();
      int idx=0;
      for (      Class<?> parameterType : parameterTypes) {
        List<Annotation> annotations=Arrays.asList(parameterAnnotations[idx]);
        Type genericType=candidateConstructor.getGenericParameterTypes()[idx];
        parameterValues[idx]=manufactureParameterValue(parameterType,genericType,annotations,typeArgsMap,genericTypeArgsExtra,pojos,genericTypeArgs);
        idx++;
      }
    }
    try {
      retValue=candidateConstructor.invoke(pojoClass,parameterValues);
      LOG.debug("String_Node_Str" + candidateConstructor);
    }
 catch (    Exception t) {
      LOG.debug("String_Node_Str" + candidateConstructor + "String_Node_Str",t);
    }
  }
  if (retValue == null) {
    retValue=externalFactory.manufacturePojo(pojoClass,genericTypeArgs);
  }
  if (retValue == null) {
    LOG.warn("String_Node_Str" + "String_Node_Str",pojoClass);
  }
  return retValue;
}

Fixed version (ground truth):
/** 
 * It attempts to create an instance of the given class <p> This method attempts to create an instance of the given argument for classes without setters. These may be either immutable classes (e.g. with final attributes and no setters) or Java classes (e.g. belonging to the java / javax namespace). In case the class does not provide a public, no-arg constructor (e.g. Calendar), this method attempts to find a , no-args, factory method (e.g. getInstance()) and it invokes it </p>
 * @param pojoClass The name of the class for which an instance filled with values is required
 * @param pojos Set of manufactured pojos' types
 * @param genericTypeArgs The generic type arguments for the current generic class instance
 * @return An instance of the given class
 * @throws IllegalArgumentException If an illegal argument was passed to the constructor
 * @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 it was not possible to create a class from a string
 */
private Object instantiatePojoWithoutConstructors(Class<?> pojoClass,Map<Class<?>,Integer> pojos,Type... genericTypeArgs) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException {
  Object retValue=null;
  final Map<String,Type> typeArgsMap=new HashMap<String,Type>();
  Type[] genericTypeArgsExtra=fillTypeArgMap(typeArgsMap,pojoClass,genericTypeArgs);
  Method[] declaredMethods=pojoClass.getDeclaredMethods();
  strategy.sort(declaredMethods);
  Object[] parameterValues=null;
  Object[] noParams=new Object[]{};
  for (  Method candidateConstructor : declaredMethods) {
    if (!Modifier.isStatic(candidateConstructor.getModifiers()) || !candidateConstructor.getReturnType().equals(pojoClass) || retValue != null) {
      continue;
    }
    parameterValues=new Object[candidateConstructor.getParameterTypes().length];
    Class<?>[] parameterTypes=candidateConstructor.getParameterTypes();
    if (parameterTypes.length == 0) {
      parameterValues=noParams;
    }
 else {
      Annotation[][] parameterAnnotations=candidateConstructor.getParameterAnnotations();
      int idx=0;
      for (      Class<?> parameterType : parameterTypes) {
        List<Annotation> annotations=Arrays.asList(parameterAnnotations[idx]);
        Type genericType=candidateConstructor.getGenericParameterTypes()[idx];
        parameterValues[idx]=manufactureParameterValue(parameterType,genericType,annotations,typeArgsMap,pojos,genericTypeArgsExtra == null ? NO_TYPES : genericTypeArgsExtra);
        idx++;
      }
    }
    try {
      retValue=candidateConstructor.invoke(pojoClass,parameterValues);
      LOG.debug("String_Node_Str" + candidateConstructor);
    }
 catch (    Exception t) {
      LOG.debug("String_Node_Str" + candidateConstructor + "String_Node_Str",t);
    }
  }
  if (retValue == null) {
    retValue=externalFactory.manufacturePojo(pojoClass,genericTypeArgs);
  }
  if (retValue == null) {
    LOG.warn("String_Node_Str" + "String_Node_Str",pojoClass);
  }
  return retValue;
}