Program: 64563
Project: 64563
Buggy source:
private void processAdditionalClasses(JavaClass cls,TypeMappingInfo tmi,ArrayList<JavaClass> extraClasses,ArrayList<JavaClass> classesToProcess){
  Class xmlElementType=null;
  JavaClass javaClass=cls;
  if (tmi != null) {
    Class adapterClass=this.typeMappingInfoToAdapterClasses.get(tmi);
    if (adapterClass != null) {
      JavaClass adapterJavaClass=helper.getJavaClass(adapterClass);
      JavaClass newType=helper.getJavaClass(Object.class);
      for (      Object nextMethod : adapterJavaClass.getDeclaredMethods()) {
        JavaMethod method=(JavaMethod)nextMethod;
        if (method.getName().equals("String_Node_Str")) {
          JavaClass returnType=method.getReturnType();
          if (!returnType.getQualifiedName().equals(newType.getQualifiedName())) {
            newType=(JavaClass)returnType;
            break;
          }
        }
      }
      if (!helper.isBuiltInJavaType(javaClass)) {
        extraClasses.add(javaClass);
      }
      javaClass=newType;
    }
    java.lang.annotation.Annotation[] annotations=getAnnotations(tmi);
    if (annotations != null) {
      for (int j=0; j < annotations.length; j++) {
        java.lang.annotation.Annotation nextAnnotation=annotations[j];
        if (nextAnnotation != null) {
          if (nextAnnotation instanceof XmlElement) {
            XmlElement javaAnnotation=(XmlElement)nextAnnotation;
            if (javaAnnotation.type() != XmlElement.DEFAULT.class) {
              xmlElementType=javaAnnotation.type();
            }
          }
        }
      }
    }
  }
  if (areEquals(javaClass,byte[].class) || areEquals(javaClass,JAVAX_ACTIVATION_DATAHANDLER) || areEquals(javaClass,Source.class)|| areEquals(javaClass,Image.class)|| areEquals(javaClass,JAVAX_MAIL_INTERNET_MIMEMULTIPART)) {
    if (tmi == null || tmi.getXmlTagName() == null) {
      ElementDeclaration declaration=new ElementDeclaration(null,javaClass,javaClass.getQualifiedName(),false,XmlElementDecl.GLOBAL.class);
      declaration.setTypeMappingInfo(tmi);
      this.localElements.add(declaration);
    }
  }
 else   if (javaClass.isArray()) {
    if (!helper.isBuiltInJavaType(javaClass.getComponentType())) {
      extraClasses.add(javaClass.getComponentType());
    }
    Class generatedClass;
    if (null == tmi) {
      generatedClass=arrayClassesToGeneratedClasses.get(javaClass.getName());
    }
 else {
      generatedClass=CompilerHelper.getExisitingGeneratedClass(tmi,typeMappingInfoToGeneratedClasses,typeMappingInfoToAdapterClasses,helper.getClassLoader());
    }
    if (generatedClass == null) {
      generatedClass=generateWrapperForArrayClass(javaClass,tmi,xmlElementType,extraClasses);
      extraClasses.add(helper.getJavaClass(generatedClass));
      arrayClassesToGeneratedClasses.put(javaClass.getName(),generatedClass);
    }
    generatedClassesToArrayClasses.put(generatedClass,javaClass);
    typeMappingInfoToGeneratedClasses.put(tmi,generatedClass);
  }
 else   if (isCollectionType(javaClass)) {
    JavaClass componentClass;
    Collection args=javaClass.getActualTypeArguments();
    if (args.size() > 0) {
      componentClass=(JavaClass)args.iterator().next();
      if (!componentClass.isPrimitive()) {
        extraClasses.add(componentClass);
      }
    }
 else {
      componentClass=helper.getJavaClass(Object.class);
    }
    Class generatedClass=CompilerHelper.getExisitingGeneratedClass(tmi,typeMappingInfoToGeneratedClasses,typeMappingInfoToAdapterClasses,helper.getClassLoader());
    if (generatedClass == null) {
      generatedClass=generateCollectionValue(javaClass,tmi,xmlElementType,extraClasses);
      extraClasses.add(helper.getJavaClass(generatedClass));
    }
    typeMappingInfoToGeneratedClasses.put(tmi,generatedClass);
  }
 else   if (isMapType(javaClass)) {
    JavaClass keyClass;
    JavaClass valueClass;
    Collection args=javaClass.getActualTypeArguments();
    Iterator argsIter=args.iterator();
    if (args.size() > 1) {
      keyClass=(JavaClass)argsIter.next();
      if (!helper.isBuiltInJavaType(keyClass)) {
        extraClasses.add(keyClass);
      }
      valueClass=(JavaClass)argsIter.next();
      if (!helper.isBuiltInJavaType(valueClass)) {
        extraClasses.add(valueClass);
      }
    }
 else {
      keyClass=helper.getJavaClass(Object.class);
      valueClass=helper.getJavaClass(Object.class);
    }
    Class generatedClass=CompilerHelper.getExisitingGeneratedClass(tmi,typeMappingInfoToGeneratedClasses,typeMappingInfoToAdapterClasses,helper.getClassLoader());
    if (generatedClass == null) {
      generatedClass=generateWrapperForMapClass(javaClass,keyClass,valueClass,tmi);
      extraClasses.add(helper.getJavaClass(generatedClass));
    }
    typeMappingInfoToGeneratedClasses.put(tmi,generatedClass);
  }
 else {
    processClass(javaClass,classesToProcess);
  }
}

Fixed version (ground truth):
private void processAdditionalClasses(JavaClass cls,TypeMappingInfo tmi,ArrayList<JavaClass> extraClasses,ArrayList<JavaClass> classesToProcess){
  Class xmlElementType=null;
  JavaClass javaClass=cls;
  if (tmi != null) {
    Class adapterClass=this.typeMappingInfoToAdapterClasses.get(tmi);
    if (adapterClass != null) {
      JavaClass adapterJavaClass=helper.getJavaClass(adapterClass);
      JavaClass newType=helper.getJavaClass(Object.class);
      for (      Object nextMethod : adapterJavaClass.getDeclaredMethods()) {
        JavaMethod method=(JavaMethod)nextMethod;
        if (method.getName().equals("String_Node_Str")) {
          JavaClass returnType=method.getReturnType();
          if (!returnType.getQualifiedName().equals(newType.getQualifiedName())) {
            newType=(JavaClass)returnType;
            break;
          }
        }
      }
      if (!helper.isBuiltInJavaType(javaClass)) {
        extraClasses.add(javaClass);
      }
      javaClass=newType;
    }
    java.lang.annotation.Annotation[] annotations=getAnnotations(tmi);
    if (annotations != null) {
      for (int j=0; j < annotations.length; j++) {
        java.lang.annotation.Annotation nextAnnotation=annotations[j];
        if (nextAnnotation != null) {
          if (nextAnnotation instanceof XmlElement) {
            XmlElement javaAnnotation=(XmlElement)nextAnnotation;
            if (javaAnnotation.type() != XmlElement.DEFAULT.class) {
              xmlElementType=javaAnnotation.type();
            }
          }
        }
      }
    }
  }
  if (areEquals(javaClass,byte[].class) || areEquals(javaClass,JAVAX_ACTIVATION_DATAHANDLER) || areEquals(javaClass,Source.class)|| areEquals(javaClass,Image.class)|| areEquals(javaClass,JAVAX_MAIL_INTERNET_MIMEMULTIPART)) {
    if (tmi == null || tmi.getXmlTagName() == null) {
      ElementDeclaration declaration=new ElementDeclaration(null,javaClass,javaClass.getQualifiedName(),false,XmlElementDecl.GLOBAL.class);
      declaration.setTypeMappingInfo(tmi);
      this.localElements.add(declaration);
    }
  }
 else   if (javaClass.isArray()) {
    if (!helper.isBuiltInJavaType(javaClass.getComponentType())) {
      extraClasses.add(javaClass.getComponentType());
    }
    Class generatedClass;
    if (null == tmi) {
      generatedClass=arrayClassesToGeneratedClasses.get(javaClass.getName());
    }
 else {
      generatedClass=CompilerHelper.getExisitingGeneratedClass(tmi,typeMappingInfoToGeneratedClasses,typeMappingInfoToAdapterClasses,helper.getClassLoader());
    }
    if (generatedClass == null) {
      generatedClass=generateWrapperForArrayClass(javaClass,tmi,xmlElementType,extraClasses);
      extraClasses.add(helper.getJavaClass(generatedClass));
      arrayClassesToGeneratedClasses.put(javaClass.getName(),generatedClass);
    }
    generatedClassesToArrayClasses.put(generatedClass,javaClass);
    typeMappingInfoToGeneratedClasses.put(tmi,generatedClass);
  }
 else   if (helper.isCollectionType(javaClass)) {
    JavaClass componentClass;
    Collection args=javaClass.getActualTypeArguments();
    if (args.size() > 0) {
      componentClass=(JavaClass)args.iterator().next();
      if (!componentClass.isPrimitive()) {
        extraClasses.add(componentClass);
      }
    }
 else {
      componentClass=helper.getJavaClass(Object.class);
    }
    Class generatedClass=CompilerHelper.getExisitingGeneratedClass(tmi,typeMappingInfoToGeneratedClasses,typeMappingInfoToAdapterClasses,helper.getClassLoader());
    if (generatedClass == null) {
      generatedClass=generateCollectionValue(javaClass,tmi,xmlElementType,extraClasses);
      extraClasses.add(helper.getJavaClass(generatedClass));
    }
    typeMappingInfoToGeneratedClasses.put(tmi,generatedClass);
  }
 else   if (helper.isMapType(javaClass)) {
    JavaClass keyClass;
    JavaClass valueClass;
    Collection args=javaClass.getActualTypeArguments();
    Iterator argsIter=args.iterator();
    if (args.size() > 1) {
      keyClass=(JavaClass)argsIter.next();
      if (!helper.isBuiltInJavaType(keyClass)) {
        extraClasses.add(keyClass);
      }
      valueClass=(JavaClass)argsIter.next();
      if (!helper.isBuiltInJavaType(valueClass)) {
        extraClasses.add(valueClass);
      }
    }
 else {
      keyClass=helper.getJavaClass(Object.class);
      valueClass=helper.getJavaClass(Object.class);
    }
    Class generatedClass=CompilerHelper.getExisitingGeneratedClass(tmi,typeMappingInfoToGeneratedClasses,typeMappingInfoToAdapterClasses,helper.getClassLoader());
    if (generatedClass == null) {
      generatedClass=generateWrapperForMapClass(javaClass,keyClass,valueClass,tmi);
      extraClasses.add(helper.getJavaClass(generatedClass));
    }
    typeMappingInfoToGeneratedClasses.put(tmi,generatedClass);
  }
 else {
    processClass(javaClass,classesToProcess);
  }
}