Program: 66733
Project: 66733
Buggy source:
/** 
 * INTERNAL:
 */
protected void generateCanonicalModelClass(Element element,PersistenceUnit persistenceUnit) throws IOException {
  Writer writer=null;
  try {
    ClassAccessor accessor=persistenceUnit.getClassAccessor(element);
    String qualifiedName=accessor.getAccessibleObjectName();
    String className=getName(qualifiedName);
    String classPackage=getPackage(qualifiedName);
    String qualifiedCanonicalName=persistenceUnit.getQualifiedCanonicalName(qualifiedName);
    String canonicalName=getName(qualifiedCanonicalName);
    String canonicalpackage=getPackage(qualifiedCanonicalName);
    JavaFileObject file=processingEnv.getFiler().createSourceFile(qualifiedCanonicalName,element);
    writer=file.openWriter();
    if (!canonicalpackage.equals("String_Node_Str")) {
      writer.append("String_Node_Str" + canonicalpackage + "String_Node_Str");
    }
    ArrayList<String> attributes=new ArrayList<String>();
    HashMap<String,String> imports=new HashMap<String,String>();
    if (!classPackage.equals(canonicalpackage)) {
      imports.put(className,qualifiedName);
    }
    for (    MappingAccessor mappingAccessor : accessor.getDescriptor().getAccessors()) {
      if (!mappingAccessor.isTransient()) {
        MetadataAnnotatedElement annotatedElement=mappingAccessor.getAnnotatedElement();
        MetadataClass rawClass=annotatedElement.getRawClass(mappingAccessor.getDescriptor());
        String attributeType;
        String types=className;
        if (mappingAccessor.isBasic()) {
          types=types + "String_Node_Str" + getUnqualifiedType(getBoxedType(annotatedElement),imports);
          attributeType=AttributeType.SingularAttribute.name();
          imports.put(attributeType,"String_Node_Str");
        }
 else {
          if (rawClass.isList()) {
            attributeType=AttributeType.ListAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else           if (rawClass.isSet()) {
            attributeType=AttributeType.SetAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else           if (rawClass.isMap()) {
            attributeType=AttributeType.MapAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else           if (rawClass.isCollection()) {
            attributeType=AttributeType.CollectionAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else {
            attributeType=AttributeType.SingularAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
          if (mappingAccessor.isMapAccessor()) {
            if (mappingAccessor.isMappedKeyMapAccessor()) {
              MetadataClass mapKeyClass=((MappedKeyMapAccessor)mappingAccessor).getMapKeyClass();
              types=types + "String_Node_Str" + getUnqualifiedType(mapKeyClass.getName(),imports)+ "String_Node_Str"+ getUnqualifiedType(mappingAccessor.getReferenceClassName(),imports);
            }
 else {
              String mapKeyType;
              if (annotatedElement.isGenericCollectionType()) {
                mapKeyType=annotatedElement.getGenericType().get(1);
              }
 else {
                if (mappingAccessor.getReferenceDescriptor().hasIdAccessor()) {
                  mapKeyType=mappingAccessor.getReferenceDescriptor().getIdAccessors().get(0).getAnnotatedElement().getType();
                }
 else {
                  mapKeyType=TypeVisitor.GENERIC_TYPE;
                }
              }
              types=types + "String_Node_Str" + getUnqualifiedType(mapKeyType,imports)+ "String_Node_Str"+ getUnqualifiedType(mappingAccessor.getReferenceClassName(),imports);
            }
          }
 else {
            types=types + "String_Node_Str" + getUnqualifiedType(mappingAccessor.getReferenceClassName(),imports);
          }
        }
        attributes.add("String_Node_Str" + attributeType + "String_Node_Str"+ types+ "String_Node_Str"+ annotatedElement.getAttributeName()+ "String_Node_Str");
      }
    }
    String parent=writeImportStatements(imports,accessor,writer,persistenceUnit,canonicalpackage);
    writer.append("String_Node_Str" + new Date() + "String_Node_Str");
    writer.append("String_Node_Str" + className + "String_Node_Str");
    int modifier=accessor.getAccessibleObject().getModifiers();
    writer.append(java.lang.reflect.Modifier.toString(modifier) + "String_Node_Str" + canonicalName);
    if (parent == null) {
      writer.append("String_Node_Str");
    }
 else {
      writer.append("String_Node_Str" + parent + "String_Node_Str");
    }
    for (    String str : attributes) {
      writer.append(str);
    }
    writer.append("String_Node_Str");
  }
  finally {
    if (writer != null) {
      writer.flush();
      writer.close();
      writer=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
protected void generateCanonicalModelClass(Element element,PersistenceUnit persistenceUnit) throws IOException {
  Writer writer=null;
  try {
    ClassAccessor accessor=persistenceUnit.getClassAccessor(element);
    String qualifiedName=accessor.getAccessibleObjectName();
    String className=getName(qualifiedName);
    String classPackage=getPackage(qualifiedName);
    String qualifiedCanonicalName=persistenceUnit.getQualifiedCanonicalName(qualifiedName);
    String canonicalName=getName(qualifiedCanonicalName);
    String canonicalpackage=getPackage(qualifiedCanonicalName);
    JavaFileObject file=processingEnv.getFiler().createSourceFile(qualifiedCanonicalName,element);
    writer=file.openWriter();
    if (!canonicalpackage.equals("String_Node_Str")) {
      writer.append("String_Node_Str" + canonicalpackage + "String_Node_Str");
    }
    ArrayList<String> attributes=new ArrayList<String>();
    HashMap<String,String> imports=new HashMap<String,String>();
    if (!classPackage.equals(canonicalpackage)) {
      imports.put(className,qualifiedName);
    }
    for (    MappingAccessor mappingAccessor : accessor.getDescriptor().getAccessors()) {
      if (!mappingAccessor.isTransient()) {
        MetadataAnnotatedElement annotatedElement=mappingAccessor.getAnnotatedElement();
        MetadataClass rawClass=annotatedElement.getRawClass(mappingAccessor.getDescriptor());
        String attributeType;
        String types=className;
        if (mappingAccessor.isBasic()) {
          types=types + "String_Node_Str" + getUnqualifiedType(getBoxedType(annotatedElement),imports);
          attributeType=AttributeType.SingularAttribute.name();
          imports.put(attributeType,"String_Node_Str");
        }
 else {
          if (rawClass.isList()) {
            attributeType=AttributeType.ListAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else           if (rawClass.isSet()) {
            attributeType=AttributeType.SetAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else           if (rawClass.isMap()) {
            attributeType=AttributeType.MapAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else           if (rawClass.isCollection()) {
            attributeType=AttributeType.CollectionAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
 else {
            attributeType=AttributeType.SingularAttribute.name();
            imports.put(attributeType,"String_Node_Str");
          }
          if (mappingAccessor.isMapAccessor()) {
            if (mappingAccessor.isMappedKeyMapAccessor()) {
              MetadataClass mapKeyClass=((MappedKeyMapAccessor)mappingAccessor).getMapKeyClass();
              types=types + "String_Node_Str" + getUnqualifiedType(mapKeyClass.getName(),imports)+ "String_Node_Str"+ getUnqualifiedType(mappingAccessor.getReferenceClassName(),imports);
            }
 else {
              String mapKeyType;
              if (annotatedElement.isGenericCollectionType()) {
                mapKeyType=annotatedElement.getGenericType().get(1);
              }
 else {
                if (mappingAccessor.getReferenceDescriptor().hasIdAccessor()) {
                  mapKeyType=mappingAccessor.getReferenceDescriptor().getIdAccessors().get(0).getAnnotatedElement().getType();
                }
 else {
                  mapKeyType=TypeVisitor.GENERIC_TYPE;
                }
              }
              types=types + "String_Node_Str" + getUnqualifiedType(mapKeyType,imports)+ "String_Node_Str"+ getUnqualifiedType(mappingAccessor.getReferenceClassName(),imports);
            }
          }
 else {
            types=types + "String_Node_Str" + getUnqualifiedType(mappingAccessor.getReferenceClassName(),imports);
          }
        }
        attributes.add("String_Node_Str" + attributeType + "String_Node_Str"+ types+ "String_Node_Str"+ annotatedElement.getAttributeName()+ "String_Node_Str");
      }
    }
    String parent=writeImportStatements(imports,accessor,writer,persistenceUnit,canonicalpackage);
    writer.append("String_Node_Str" + Version.getVersion() + "String_Node_Str"+ Version.getBuildDate()+ "String_Node_Str"+ Version.getBuildRevision()+ "String_Node_Str"+ new Date()+ "String_Node_Str");
    writer.append("String_Node_Str" + className + "String_Node_Str");
    int modifier=accessor.getAccessibleObject().getModifiers();
    writer.append(java.lang.reflect.Modifier.toString(modifier) + "String_Node_Str" + canonicalName);
    if (parent == null) {
      writer.append("String_Node_Str");
    }
 else {
      writer.append("String_Node_Str" + parent + "String_Node_Str");
    }
    for (    String str : attributes) {
      writer.append(str);
    }
    writer.append("String_Node_Str");
  }
  finally {
    if (writer != null) {
      writer.flush();
      writer.close();
      writer=null;
    }
  }
}