Program: 190807
Project: 190807
Buggy source:
/** 
 * Generate the simplest XmlElement annotation possible taking all semantic optimizations into account.  This method is essentially equivalent to: xew.name(ctype.getTagName().getLocalPart()) .namespace(ctype.getTagName().getNamespaceURI()) .type(jtype) .defaultValue(ctype.getDefaultValue());
 * @param field
 * @param ctype
 * @param jtype
 * @param checkWrapper true if the method might need to generate XmlElements
 */
private void writeXmlElementAnnotation(JAnnotatable field,CTypeRef ctype,JType jtype,boolean checkWrapper){
  XmlElementWriter xew=null;
  XmlNsForm formDefault=parent()._package().getElementFormDefault();
  String mostUsedURI=parent()._package().getMostUsedNamespaceURI();
  String propName=prop.getName(false);
  String generatedName=ctype.getTagName().getLocalPart();
  if (!generatedName.equals(propName)) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.name(generatedName);
  }
  String generatedNS=ctype.getTagName().getNamespaceURI();
  if (((formDefault == XmlNsForm.QUALIFIED) && !generatedNS.equals(mostUsedURI)) || ((formDefault == XmlNsForm.UNQUALIFIED) && !generatedNS.equals("String_Node_Str"))) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.namespace(generatedNS);
  }
  if (!jtype.equals(exposedType) || (parent().parent().getModel().options.runtime14 && prop.isCollection())) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.type(jtype);
  }
  final String defaultValue=ctype.getDefaultValue();
  if (defaultValue != null) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.defaultValue(defaultValue);
  }
  if (ctype.isNillable()) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.nillable(true);
  }
}

Fixed version (ground truth):
/** 
 * Generate the simplest XmlElement annotation possible taking all semantic optimizations into account.  This method is essentially equivalent to: xew.name(ctype.getTagName().getLocalPart()) .namespace(ctype.getTagName().getNamespaceURI()) .type(jtype) .defaultValue(ctype.getDefaultValue());
 * @param field
 * @param ctype
 * @param jtype
 * @param checkWrapper true if the method might need to generate XmlElements
 */
private void writeXmlElementAnnotation(JAnnotatable field,CTypeRef ctype,JType jtype,boolean checkWrapper){
  XmlElementWriter xew=null;
  XmlNsForm formDefault=parent()._package().getElementFormDefault();
  String mostUsedURI=parent()._package().getMostUsedNamespaceURI();
  String propName=prop.getName(false);
  String generatedName=ctype.getTagName().getLocalPart();
  if (!generatedName.equals(propName)) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.name(generatedName);
  }
  String generatedNS=ctype.getTagName().getNamespaceURI();
  if (((formDefault == XmlNsForm.QUALIFIED) && !generatedNS.equals(mostUsedURI)) || ((formDefault == XmlNsForm.UNQUALIFIED) && !generatedNS.equals("String_Node_Str"))) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.namespace(generatedNS);
  }
  CElementPropertyInfo ep=(CElementPropertyInfo)prop;
  if (ep.isRequired() && exposedType.isReference()) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.required(true);
  }
  if (ep.isRequired() && !prop.isCollection())   jtype=jtype.unboxify();
  if (!jtype.equals(exposedType) || (parent().parent().getModel().options.runtime14 && prop.isCollection())) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.type(jtype);
  }
  final String defaultValue=ctype.getDefaultValue();
  if (defaultValue != null) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.defaultValue(defaultValue);
  }
  if (ctype.isNillable()) {
    if (xew == null)     xew=getXew(checkWrapper,field);
    xew.nillable(true);
  }
}