Program: 66590
Project: 66590
Buggy source:
private Class generateWrapperForMapClass(JavaClass mapClass,JavaClass keyClass,JavaClass valueClass,TypeMappingInfo typeMappingInfo){
  NamespaceInfo combinedNamespaceInfo=null;
  NamespaceResolver combinedNamespaceResolver=new NamespaceResolver();
  String combinedNamespaceInfoNamespace=null;
  NamespaceInfo nsForMapClass=packageToNamespaceMappings.get(mapClass.getPackageName());
  if (nsForMapClass != null) {
    combinedNamespaceInfo=nsForMapClass;
    combinedNamespaceInfoNamespace=nsForMapClass.getNamespace();
  }
 else {
    combinedNamespaceInfo=new NamespaceInfo();
  }
  String packageName="String_Node_Str";
  if (!helper.isBuiltInJavaType(keyClass)) {
    NamespaceInfo keyNamespaceInfo=getNamespaceInfoForPackage(keyClass);
    String keyPackageName=keyClass.getPackageName();
    packageName=packageName + "String_Node_Str" + keyPackageName;
    if (combinedNamespaceInfoNamespace == null) {
      TypeInfo keyTypeInfo=getTypeInfo().get(keyClass.getQualifiedName());
      if (keyTypeInfo == null && shouldGenerateTypeInfo(keyClass)) {
        JavaClass[] jClassArray=new JavaClass[]{keyClass};
        buildNewTypeInfo(jClassArray);
        keyTypeInfo=getTypeInfo().get(keyClass.getQualifiedName());
      }
      combinedNamespaceInfoNamespace=keyTypeInfo.getClassNamespace();
    }
    java.util.Vector<Namespace> namespaces=keyNamespaceInfo.getNamespaceResolver().getNamespaces();
    for (    Namespace n : namespaces) {
      combinedNamespaceResolver.put(n.getPrefix(),n.getNamespaceURI());
    }
  }
  if (!helper.isBuiltInJavaType(valueClass)) {
    NamespaceInfo valueNamespaceInfo=getNamespaceInfoForPackage(valueClass);
    String valuePackageName=valueClass.getPackageName();
    packageName=packageName + "String_Node_Str" + valuePackageName;
    java.util.Vector<Namespace> namespaces=valueNamespaceInfo.getNamespaceResolver().getNamespaces();
    for (    Namespace n : namespaces) {
      combinedNamespaceResolver.put(n.getPrefix(),n.getNamespaceURI());
    }
  }
  if (combinedNamespaceInfoNamespace == null) {
    combinedNamespaceInfoNamespace="String_Node_Str";
  }
  combinedNamespaceInfo.setNamespace(combinedNamespaceInfoNamespace);
  combinedNamespaceInfo.setNamespaceResolver(combinedNamespaceResolver);
  getPackageToNamespaceMappings().put(packageName,combinedNamespaceInfo);
  int beginIndex=keyClass.getName().lastIndexOf("String_Node_Str") + 1;
  String keyName=keyClass.getName().substring(beginIndex);
  int dollarIndex=keyName.indexOf('$');
  if (dollarIndex > -1) {
    keyName=keyName.substring(dollarIndex + 1);
  }
  beginIndex=valueClass.getName().lastIndexOf("String_Node_Str") + 1;
  String valueName=valueClass.getName().substring(beginIndex);
  dollarIndex=valueName.indexOf('$');
  if (dollarIndex > -1) {
    valueName=valueName.substring(dollarIndex + 1);
  }
  String collectionClassShortName=mapClass.getRawName().substring(mapClass.getRawName().lastIndexOf('.') + 1);
  String suggestedClassName=keyName + valueName + collectionClassShortName;
  String qualifiedClassName=packageName + "String_Node_Str" + suggestedClassName;
  qualifiedClassName=getNextAvailableClassName(qualifiedClassName);
  String qualifiedInternalClassName=qualifiedClassName.replace('.','/');
  String internalKeyName=keyClass.getQualifiedName().replace('.','/');
  String internalValueName=valueClass.getQualifiedName().replace('.','/');
  Type mapType=Type.getType("String_Node_Str" + mapClass.getRawName().replace('.','/') + "String_Node_Str");
  ClassWriter cw=new ClassWriter(false);
  CodeVisitor cv;
  cw.visit(Constants.V1_5,Constants.ACC_PUBLIC + Constants.ACC_SUPER,qualifiedInternalClassName,"String_Node_Str",null,"String_Node_Str");
  RuntimeVisibleAnnotations fieldAttrs1=new RuntimeVisibleAnnotations();
  if (typeMappingInfo != null) {
    java.lang.annotation.Annotation[] annotations=typeMappingInfo.getAnnotations();
    if (annotations != null) {
      for (int i=0; i < annotations.length; i++) {
        java.lang.annotation.Annotation nextAnnotation=annotations[i];
        if (nextAnnotation != null && !(nextAnnotation instanceof XmlElement) && !(nextAnnotation instanceof XmlJavaTypeAdapter)) {
          String annotationClassName=nextAnnotation.annotationType().getName();
          Annotation fieldAttrs1ann0=new Annotation("String_Node_Str" + annotationClassName.replace('.','/') + "String_Node_Str");
          fieldAttrs1.annotations.add(fieldAttrs1ann0);
          for (          Method next : nextAnnotation.annotationType().getDeclaredMethods()) {
            try {
              Object nextValue=next.invoke(nextAnnotation,new Object[]{});
              if (nextValue instanceof Class) {
                Type nextType=Type.getType("String_Node_Str" + ((Class)nextValue).getName().replace('.','/') + "String_Node_Str");
                nextValue=nextType;
              }
              fieldAttrs1ann0.add(next.getName(),nextValue);
            }
 catch (            InvocationTargetException ex) {
            }
catch (            IllegalAccessException ex) {
            }
          }
        }
      }
    }
  }
  SignatureAttribute fieldAttrs2=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  fieldAttrs1.next=fieldAttrs2;
  cw.visitField(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str",null,fieldAttrs1);
  cv=cw.visitMethod(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitMethodInsn(Constants.INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str");
  cv.visitInsn(Constants.RETURN);
  cv.visitMaxs(1,1);
  RuntimeVisibleAnnotations methodAttrs1=new RuntimeVisibleAnnotations();
  Annotation methodAttrs1ann0=new Annotation("String_Node_Str");
  methodAttrs1.annotations.add(methodAttrs1ann0);
  SignatureAttribute methodAttrs2=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  methodAttrs1.next=methodAttrs2;
  cv=cw.visitMethod(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str",null,methodAttrs1);
  Label l0=new Label();
  cv.visitLabel(l0);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitVarInsn(Constants.ALOAD,1);
  cv.visitFieldInsn(Constants.PUTFIELD,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.RETURN);
  Label l1=new Label();
  cv.visitLabel(l1);
  LocalVariableTypeTableAttribute cvAttr=new LocalVariableTypeTableAttribute();
  cv.visitAttribute(cvAttr);
  cv.visitMaxs(2,2);
  methodAttrs1=new RuntimeVisibleAnnotations();
  methodAttrs1ann0=new Annotation("String_Node_Str");
  methodAttrs1.annotations.add(methodAttrs1ann0);
  methodAttrs2=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  methodAttrs1.next=methodAttrs2;
  cv=cw.visitMethod(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str",null,methodAttrs1);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitFieldInsn(Constants.GETFIELD,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.ARETURN);
  cv.visitMaxs(1,1);
  cv=cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_BRIDGE + Constants.ACC_SYNTHETIC,"String_Node_Str","String_Node_Str",null,null);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitMethodInsn(Constants.INVOKEVIRTUAL,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.ARETURN);
  cv.visitMaxs(1,1);
  cv=cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_BRIDGE + Constants.ACC_SYNTHETIC,"String_Node_Str","String_Node_Str",null,null);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitVarInsn(Constants.ALOAD,1);
  cv.visitTypeInsn(Constants.CHECKCAST,mapType.getInternalName());
  cv.visitMethodInsn(Constants.INVOKEVIRTUAL,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.RETURN);
  cv.visitMaxs(2,2);
  SignatureAttribute attr=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  cw.visitAttribute(attr);
  cw.visitEnd();
  byte[] classBytes=cw.toByteArray();
  return generateClassFromBytes(qualifiedClassName,classBytes);
}

Fixed version (ground truth):
private Class generateWrapperForMapClass(JavaClass mapClass,JavaClass keyClass,JavaClass valueClass,TypeMappingInfo typeMappingInfo){
  NamespaceInfo combinedNamespaceInfo=null;
  NamespaceResolver combinedNamespaceResolver=new NamespaceResolver();
  String combinedNamespaceInfoNamespace=null;
  NamespaceInfo nsForMapClass=packageToNamespaceMappings.get(mapClass.getPackageName());
  if (nsForMapClass != null) {
    combinedNamespaceInfo=nsForMapClass;
    combinedNamespaceInfoNamespace=nsForMapClass.getNamespace();
  }
 else {
    combinedNamespaceInfo=new NamespaceInfo();
  }
  String packageName="String_Node_Str";
  if (!helper.isBuiltInJavaType(keyClass)) {
    NamespaceInfo keyNamespaceInfo=getNamespaceInfoForPackage(keyClass);
    String keyPackageName=keyClass.getPackageName();
    packageName=packageName + "String_Node_Str" + keyPackageName;
    if (combinedNamespaceInfoNamespace == null) {
      TypeInfo keyTypeInfo=getTypeInfo().get(keyClass.getQualifiedName());
      if (keyTypeInfo == null && shouldGenerateTypeInfo(keyClass)) {
        JavaClass[] jClassArray=new JavaClass[]{keyClass};
        buildNewTypeInfo(jClassArray);
        keyTypeInfo=getTypeInfo().get(keyClass.getQualifiedName());
      }
      combinedNamespaceInfoNamespace=keyTypeInfo.getClassNamespace();
    }
    java.util.Vector<Namespace> namespaces=keyNamespaceInfo.getNamespaceResolver().getNamespaces();
    for (    Namespace n : namespaces) {
      combinedNamespaceResolver.put(n.getPrefix(),n.getNamespaceURI());
    }
  }
  if (!helper.isBuiltInJavaType(valueClass)) {
    NamespaceInfo valueNamespaceInfo=getNamespaceInfoForPackage(valueClass);
    String valuePackageName=valueClass.getPackageName();
    packageName=packageName + "String_Node_Str" + valuePackageName;
    java.util.Vector<Namespace> namespaces=valueNamespaceInfo.getNamespaceResolver().getNamespaces();
    for (    Namespace n : namespaces) {
      combinedNamespaceResolver.put(n.getPrefix(),n.getNamespaceURI());
    }
  }
  if (combinedNamespaceInfoNamespace == null) {
    if (this.defaultTargetNamespace != null) {
      combinedNamespaceInfoNamespace=this.defaultTargetNamespace;
    }
 else {
      combinedNamespaceInfoNamespace="String_Node_Str";
    }
  }
  combinedNamespaceInfo.setNamespace(combinedNamespaceInfoNamespace);
  combinedNamespaceInfo.setNamespaceResolver(combinedNamespaceResolver);
  getPackageToNamespaceMappings().put(packageName,combinedNamespaceInfo);
  int beginIndex=keyClass.getName().lastIndexOf("String_Node_Str") + 1;
  String keyName=keyClass.getName().substring(beginIndex);
  int dollarIndex=keyName.indexOf('$');
  if (dollarIndex > -1) {
    keyName=keyName.substring(dollarIndex + 1);
  }
  beginIndex=valueClass.getName().lastIndexOf("String_Node_Str") + 1;
  String valueName=valueClass.getName().substring(beginIndex);
  dollarIndex=valueName.indexOf('$');
  if (dollarIndex > -1) {
    valueName=valueName.substring(dollarIndex + 1);
  }
  String collectionClassShortName=mapClass.getRawName().substring(mapClass.getRawName().lastIndexOf('.') + 1);
  String suggestedClassName=keyName + valueName + collectionClassShortName;
  String qualifiedClassName=packageName + "String_Node_Str" + suggestedClassName;
  qualifiedClassName=getNextAvailableClassName(qualifiedClassName);
  String qualifiedInternalClassName=qualifiedClassName.replace('.','/');
  String internalKeyName=keyClass.getQualifiedName().replace('.','/');
  String internalValueName=valueClass.getQualifiedName().replace('.','/');
  Type mapType=Type.getType("String_Node_Str" + mapClass.getRawName().replace('.','/') + "String_Node_Str");
  ClassWriter cw=new ClassWriter(false);
  CodeVisitor cv;
  cw.visit(Constants.V1_5,Constants.ACC_PUBLIC + Constants.ACC_SUPER,qualifiedInternalClassName,"String_Node_Str",null,"String_Node_Str");
  RuntimeVisibleAnnotations fieldAttrs1=new RuntimeVisibleAnnotations();
  if (typeMappingInfo != null) {
    java.lang.annotation.Annotation[] annotations=typeMappingInfo.getAnnotations();
    if (annotations != null) {
      for (int i=0; i < annotations.length; i++) {
        java.lang.annotation.Annotation nextAnnotation=annotations[i];
        if (nextAnnotation != null && !(nextAnnotation instanceof XmlElement) && !(nextAnnotation instanceof XmlJavaTypeAdapter)) {
          String annotationClassName=nextAnnotation.annotationType().getName();
          Annotation fieldAttrs1ann0=new Annotation("String_Node_Str" + annotationClassName.replace('.','/') + "String_Node_Str");
          fieldAttrs1.annotations.add(fieldAttrs1ann0);
          for (          Method next : nextAnnotation.annotationType().getDeclaredMethods()) {
            try {
              Object nextValue=next.invoke(nextAnnotation,new Object[]{});
              if (nextValue instanceof Class) {
                Type nextType=Type.getType("String_Node_Str" + ((Class)nextValue).getName().replace('.','/') + "String_Node_Str");
                nextValue=nextType;
              }
              fieldAttrs1ann0.add(next.getName(),nextValue);
            }
 catch (            InvocationTargetException ex) {
            }
catch (            IllegalAccessException ex) {
            }
          }
        }
      }
    }
  }
  SignatureAttribute fieldAttrs2=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  fieldAttrs1.next=fieldAttrs2;
  cw.visitField(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str",null,fieldAttrs1);
  cv=cw.visitMethod(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str",null,null);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitMethodInsn(Constants.INVOKESPECIAL,"String_Node_Str","String_Node_Str","String_Node_Str");
  cv.visitInsn(Constants.RETURN);
  cv.visitMaxs(1,1);
  RuntimeVisibleAnnotations methodAttrs1=new RuntimeVisibleAnnotations();
  Annotation methodAttrs1ann0=new Annotation("String_Node_Str");
  methodAttrs1.annotations.add(methodAttrs1ann0);
  SignatureAttribute methodAttrs2=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  methodAttrs1.next=methodAttrs2;
  cv=cw.visitMethod(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str",null,methodAttrs1);
  Label l0=new Label();
  cv.visitLabel(l0);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitVarInsn(Constants.ALOAD,1);
  cv.visitFieldInsn(Constants.PUTFIELD,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.RETURN);
  Label l1=new Label();
  cv.visitLabel(l1);
  LocalVariableTypeTableAttribute cvAttr=new LocalVariableTypeTableAttribute();
  cv.visitAttribute(cvAttr);
  cv.visitMaxs(2,2);
  methodAttrs1=new RuntimeVisibleAnnotations();
  methodAttrs1ann0=new Annotation("String_Node_Str");
  methodAttrs1.annotations.add(methodAttrs1ann0);
  methodAttrs2=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  methodAttrs1.next=methodAttrs2;
  cv=cw.visitMethod(Constants.ACC_PUBLIC,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str",null,methodAttrs1);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitFieldInsn(Constants.GETFIELD,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.ARETURN);
  cv.visitMaxs(1,1);
  cv=cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_BRIDGE + Constants.ACC_SYNTHETIC,"String_Node_Str","String_Node_Str",null,null);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitMethodInsn(Constants.INVOKEVIRTUAL,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.ARETURN);
  cv.visitMaxs(1,1);
  cv=cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_BRIDGE + Constants.ACC_SYNTHETIC,"String_Node_Str","String_Node_Str",null,null);
  cv.visitVarInsn(Constants.ALOAD,0);
  cv.visitVarInsn(Constants.ALOAD,1);
  cv.visitTypeInsn(Constants.CHECKCAST,mapType.getInternalName());
  cv.visitMethodInsn(Constants.INVOKEVIRTUAL,qualifiedInternalClassName,"String_Node_Str","String_Node_Str" + mapType.getInternalName() + "String_Node_Str");
  cv.visitInsn(Constants.RETURN);
  cv.visitMaxs(2,2);
  SignatureAttribute attr=new SignatureAttribute("String_Node_Str" + mapType.getInternalName() + "String_Node_Str"+ internalKeyName+ "String_Node_Str"+ internalValueName+ "String_Node_Str");
  cw.visitAttribute(attr);
  cw.visitEnd();
  byte[] classBytes=cw.toByteArray();
  return generateClassFromBytes(qualifiedClassName,classBytes);
}