Program: 64630
Project: 64630
Buggy source:
private Class generateCollectionValue(JavaClass collectionClass,TypeMappingInfo typeMappingInfo,Class xmlElementType,List<JavaClass> classesToProcess){
  JavaClass componentClass;
  if (typeMappingInfo != null && xmlElementType != null) {
    componentClass=helper.getJavaClass(xmlElementType);
  }
 else   if (collectionClass.hasActualTypeArguments()) {
    componentClass=((JavaClass)collectionClass.getActualTypeArguments().toArray()[0]);
  }
 else {
    componentClass=helper.getJavaClass(Object.class);
  }
  boolean multiDimensional=false;
  if (componentClass.isPrimitive()) {
    Class primitiveClass=getPrimitiveClass(componentClass.getRawName());
    componentClass=helper.getJavaClass(getObjectClass(primitiveClass));
  }
 else   if (helper.getJavaClass(Collection.class).isAssignableFrom(componentClass)) {
    multiDimensional=true;
    Class nestedCollectionClass=collectionClassesToGeneratedClasses.get(componentClass.getName());
    if (nestedCollectionClass == null) {
      nestedCollectionClass=generateCollectionValue(componentClass,typeMappingInfo,xmlElementType,classesToProcess);
      arrayClassesToGeneratedClasses.put(componentClass.getName(),nestedCollectionClass);
      classesToProcess.add(helper.getJavaClass(nestedCollectionClass));
    }
    componentClass=helper.getJavaClass(nestedCollectionClass);
  }
 else   if (componentClass.isArray()) {
    if (componentClass.getName().equals("String_Node_Str")) {
      multiDimensional=false;
    }
 else {
      multiDimensional=true;
      Class nestedArrayClass=arrayClassesToGeneratedClasses.get(componentClass.getName());
      if (nestedArrayClass == null) {
        nestedArrayClass=generateWrapperForArrayClass(componentClass,typeMappingInfo,xmlElementType,classesToProcess);
        arrayClassesToGeneratedClasses.put(componentClass.getName(),nestedArrayClass);
      }
      componentClass=helper.getJavaClass(nestedArrayClass);
    }
  }
  PackageInfo packageInfo=packageToPackageInfoMappings.get(collectionClass.getPackageName());
  String namespace=EMPTY_STRING;
  if (this.defaultTargetNamespace != null) {
    namespace=this.defaultTargetNamespace;
  }
  PackageInfo componentNamespaceInfo=getPackageInfoForPackage(componentClass);
  String packageName=componentClass.getPackageName();
  packageName="String_Node_Str" + packageName;
  if (packageInfo == null) {
    packageInfo=getPackageToPackageInfoMappings().get(packageName);
  }
 else {
    getPackageToPackageInfoMappings().put(packageName,packageInfo);
    if (packageInfo.getNamespace() != null) {
      namespace=packageInfo.getNamespace();
    }
  }
  if (packageInfo == null) {
    if (componentNamespaceInfo != null) {
      packageInfo=componentNamespaceInfo;
    }
 else {
      packageInfo=new PackageInfo();
      packageInfo.setNamespaceInfo(new NamespaceInfo());
      packageInfo.setNamespaceResolver(new NamespaceResolver());
    }
    getPackageToPackageInfoMappings().put(packageName,packageInfo);
  }
  String name=componentClass.getName();
  if ("String_Node_Str".equals(name)) {
    name="String_Node_Str";
  }
  int beginIndex=name.lastIndexOf(DOT_CHR) + 1;
  name=name.substring(beginIndex);
  int dollarIndex=name.indexOf(DOLLAR_SIGN_CHR);
  if (dollarIndex > -1) {
    name=name.substring(dollarIndex + 1);
  }
  String collectionClassRawName=collectionClass.getRawName();
  String collectionClassShortName=collectionClassRawName.substring(collectionClassRawName.lastIndexOf(DOT_CHR) + 1);
  String suggestedClassName=collectionClassShortName + "String_Node_Str" + name;
  String qualifiedClassName=packageName + DOT_CHR + suggestedClassName;
  qualifiedClassName=getNextAvailableClassName(qualifiedClassName);
  String qualifiedInternalClassName=qualifiedClassName.replace(DOT_CHR,SLASH_CHR);
  byte[] classBytes;
  if (multiDimensional) {
    classBytes=generateMultiDimensionalManyValueClass(typeMappingInfo,namespace,MultiDimensionalCollectionValue.class,qualifiedInternalClassName,componentClass,collectionClass);
  }
 else {
    classBytes=generateManyValue(typeMappingInfo,namespace,CollectionValue.class,qualifiedInternalClassName,componentClass,collectionClass);
  }
  return generateClassFromBytes(qualifiedClassName,classBytes);
}

Fixed version (ground truth):
private Class generateCollectionValue(JavaClass collectionClass,TypeMappingInfo typeMappingInfo,Class xmlElementType,List<JavaClass> classesToProcess){
  JavaClass componentClass;
  if (typeMappingInfo != null && xmlElementType != null) {
    componentClass=helper.getJavaClass(xmlElementType);
  }
 else {
    Collection args=collectionClass.getActualTypeArguments();
    if (args.size() > 0) {
      componentClass=((JavaClass)args.toArray()[0]);
    }
 else {
      componentClass=helper.getJavaClass(Object.class);
    }
  }
  boolean multiDimensional=false;
  if (componentClass.isPrimitive()) {
    Class primitiveClass=getPrimitiveClass(componentClass.getRawName());
    componentClass=helper.getJavaClass(getObjectClass(primitiveClass));
  }
 else   if (helper.getJavaClass(Collection.class).isAssignableFrom(componentClass)) {
    multiDimensional=true;
    Class nestedCollectionClass=collectionClassesToGeneratedClasses.get(componentClass.getName());
    if (nestedCollectionClass == null) {
      nestedCollectionClass=generateCollectionValue(componentClass,typeMappingInfo,xmlElementType,classesToProcess);
      arrayClassesToGeneratedClasses.put(componentClass.getName(),nestedCollectionClass);
      classesToProcess.add(helper.getJavaClass(nestedCollectionClass));
    }
    componentClass=helper.getJavaClass(nestedCollectionClass);
  }
 else   if (componentClass.isArray()) {
    if (componentClass.getName().equals("String_Node_Str")) {
      multiDimensional=false;
    }
 else {
      multiDimensional=true;
      Class nestedArrayClass=arrayClassesToGeneratedClasses.get(componentClass.getName());
      if (nestedArrayClass == null) {
        nestedArrayClass=generateWrapperForArrayClass(componentClass,typeMappingInfo,xmlElementType,classesToProcess);
        arrayClassesToGeneratedClasses.put(componentClass.getName(),nestedArrayClass);
      }
      componentClass=helper.getJavaClass(nestedArrayClass);
    }
  }
  PackageInfo packageInfo=packageToPackageInfoMappings.get(collectionClass.getPackageName());
  String namespace=EMPTY_STRING;
  if (this.defaultTargetNamespace != null) {
    namespace=this.defaultTargetNamespace;
  }
  PackageInfo componentNamespaceInfo=getPackageInfoForPackage(componentClass);
  String packageName=componentClass.getPackageName();
  packageName="String_Node_Str" + packageName;
  if (packageInfo == null) {
    packageInfo=getPackageToPackageInfoMappings().get(packageName);
  }
 else {
    getPackageToPackageInfoMappings().put(packageName,packageInfo);
    if (packageInfo.getNamespace() != null) {
      namespace=packageInfo.getNamespace();
    }
  }
  if (packageInfo == null) {
    if (componentNamespaceInfo != null) {
      packageInfo=componentNamespaceInfo;
    }
 else {
      packageInfo=new PackageInfo();
      packageInfo.setNamespaceInfo(new NamespaceInfo());
      packageInfo.setNamespaceResolver(new NamespaceResolver());
    }
    getPackageToPackageInfoMappings().put(packageName,packageInfo);
  }
  String name=componentClass.getName();
  if ("String_Node_Str".equals(name)) {
    name="String_Node_Str";
  }
  int beginIndex=name.lastIndexOf(DOT_CHR) + 1;
  name=name.substring(beginIndex);
  int dollarIndex=name.indexOf(DOLLAR_SIGN_CHR);
  if (dollarIndex > -1) {
    name=name.substring(dollarIndex + 1);
  }
  String collectionClassRawName=collectionClass.getRawName();
  String collectionClassShortName=collectionClassRawName.substring(collectionClassRawName.lastIndexOf(DOT_CHR) + 1);
  String suggestedClassName=collectionClassShortName + "String_Node_Str" + name;
  String qualifiedClassName=packageName + DOT_CHR + suggestedClassName;
  qualifiedClassName=getNextAvailableClassName(qualifiedClassName);
  String qualifiedInternalClassName=qualifiedClassName.replace(DOT_CHR,SLASH_CHR);
  byte[] classBytes;
  if (multiDimensional) {
    classBytes=generateMultiDimensionalManyValueClass(typeMappingInfo,namespace,MultiDimensionalCollectionValue.class,qualifiedInternalClassName,componentClass,collectionClass);
  }
 else {
    classBytes=generateManyValue(typeMappingInfo,namespace,CollectionValue.class,qualifiedInternalClassName,componentClass,collectionClass);
  }
  return generateClassFromBytes(qualifiedClassName,classBytes);
}