Program: 65051
Project: 65051
Buggy source:
private XPathFragment buildRootFragment(Object object,XMLDescriptor descriptor,boolean isXMLRoot,MarshalRecord marshalRecord){
  XPathFragment rootFragment=null;
  if (isXMLRoot) {
    String xmlRootUri=((XMLRoot)object).getNamespaceURI();
    String xmlRootLocalName=((XMLRoot)object).getLocalName();
    rootFragment=new XPathFragment(xmlRootLocalName,marshalRecord.getNamespaceSeparator(),marshalRecord.isNamespaceAware());
    rootFragment.setNamespaceURI(xmlRootUri);
    if (xmlRootUri != null) {
      if (descriptor != null) {
        String xmlRootPrefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(xmlRootUri);
        if (xmlRootPrefix == null && !(xmlRootUri.equals(marshalRecord.getNamespaceResolver().getDefaultNamespaceURI()))) {
          xmlRootPrefix=marshalRecord.getNamespaceResolver().generatePrefix();
          marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
        }
        if (xmlRootPrefix == null) {
          rootFragment.setXPath(xmlRootLocalName);
        }
 else {
          rootFragment.setPrefix(xmlRootPrefix);
        }
      }
 else {
        if (marshalRecord.isNamespaceAware()) {
          String xmlRootPrefix="String_Node_Str";
          marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
          rootFragment.setXPath(xmlRootPrefix + marshalRecord.getNamespaceSeparator() + xmlRootLocalName);
        }
 else {
          rootFragment.setXPath(xmlRootLocalName);
        }
      }
    }
  }
 else {
    XMLField defaultRootField=descriptor.getDefaultRootElementField();
    if (defaultRootField != null) {
      rootFragment=defaultRootField.getXPathFragment();
    }
  }
  return rootFragment;
}

Fixed version (ground truth):
private XPathFragment buildRootFragment(Object object,XMLDescriptor descriptor,boolean isXMLRoot,MarshalRecord marshalRecord){
  XPathFragment rootFragment=null;
  if (isXMLRoot) {
    String xmlRootUri=((XMLRoot)object).getNamespaceURI();
    String xmlRootLocalName=((XMLRoot)object).getLocalName();
    rootFragment=new XPathFragment();
    rootFragment.setLocalName(xmlRootLocalName);
    rootFragment.setNamespaceURI(xmlRootUri);
    rootFragment.setNamespaceAware(marshalRecord.isNamespaceAware());
    rootFragment.setNamespaceSeparator(marshalRecord.getNamespaceSeparator());
    if (xmlRootUri != null) {
      if (descriptor != null) {
        String xmlRootPrefix=marshalRecord.getNamespaceResolver().resolveNamespaceURI(xmlRootUri);
        if (xmlRootPrefix == null && !(xmlRootUri.equals(marshalRecord.getNamespaceResolver().getDefaultNamespaceURI()))) {
          xmlRootPrefix=marshalRecord.getNamespaceResolver().generatePrefix();
          marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
        }
        if (xmlRootPrefix == null) {
          rootFragment.setXPath(xmlRootLocalName);
        }
 else {
          rootFragment.setPrefix(xmlRootPrefix);
        }
      }
 else {
        if (marshalRecord.isNamespaceAware()) {
          String xmlRootPrefix="String_Node_Str";
          marshalRecord.getNamespaceResolver().put(xmlRootPrefix,xmlRootUri);
          rootFragment.setXPath(xmlRootPrefix + marshalRecord.getNamespaceSeparator() + xmlRootLocalName);
        }
 else {
          rootFragment.setXPath(xmlRootLocalName);
        }
      }
    }
  }
 else {
    XMLField defaultRootField=descriptor.getDefaultRootElementField();
    if (defaultRootField != null) {
      rootFragment=defaultRootField.getXPathFragment();
    }
  }
  return rootFragment;
}