Program: 63713
Project: 63713
Buggy source:
/** 
 * INTERNAL: Convert the Oracle XMLDocument to the reference-class.
 */
public Object xmlToObject(DOMRecord xmlRow,Class referenceClass) throws XMLMarshalException {
  try {
    String xmlEncoding="String_Node_Str";
    String xmlVersion="String_Node_Str";
    try {
      Method getEncoding=PrivilegedAccessHelper.getMethod(xmlRow.getDocument().getClass(),"String_Node_Str",new Class[]{},true);
      Method getVersion=PrivilegedAccessHelper.getMethod(xmlRow.getDocument().getClass(),"String_Node_Str",new Class[]{},true);
      xmlEncoding=(String)PrivilegedAccessHelper.invokeMethod(getEncoding,xmlRow.getDocument(),new Object[]{});
      xmlVersion=(String)PrivilegedAccessHelper.invokeMethod(getVersion,xmlRow.getDocument(),new Object[]{});
    }
 catch (    Exception ex) {
    }
    XMLContext xmlContext=xmlUnmarshaller.getXMLContext();
    if (XMLConversionManager.getDefaultJavaTypes().get(referenceClass) != null || CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(referenceClass) || CoreClassConstants.DURATION.isAssignableFrom(referenceClass)) {
      Object nodeVal;
      try {
        Text rootTxt=(Text)xmlRow.getDOM().getFirstChild();
        nodeVal=rootTxt.getNodeValue();
      }
 catch (      Exception ex) {
        nodeVal=null;
      }
      Object obj=((XMLConversionManager)xmlContext.getSession().getDatasourcePlatform().getConversionManager()).convertObject(nodeVal,referenceClass);
      Root xmlRoot=new XMLRoot();
      xmlRoot.setObject(obj);
      String lName=xmlRow.getDOM().getLocalName();
      if (lName == null) {
        lName=xmlRow.getDOM().getNodeName();
      }
      xmlRoot.setLocalName(lName);
      xmlRoot.setNamespaceURI(xmlRow.getDOM().getNamespaceURI());
      xmlRoot.setEncoding(xmlEncoding);
      xmlRoot.setVersion(xmlVersion);
      return xmlRoot;
    }
    CoreAbstractSession readSession=xmlContext.getSession(referenceClass);
    Descriptor descriptor=(Descriptor)readSession.getDescriptor(referenceClass);
    if (descriptor == null) {
      throw XMLMarshalException.descriptorNotFoundInProject(referenceClass.getName());
    }
    Object object=null;
    if (null == xmlRow.getDOM().getAttributes().getNamedItemNS(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_NIL_ATTRIBUTE)) {
      xmlRow.setUnmarshaller(xmlUnmarshaller);
      xmlRow.setDocPresPolicy(xmlContext.getDocumentPreservationPolicy((AbstractSession)readSession));
      XMLObjectBuilder objectBuilder=(XMLObjectBuilder)descriptor.getObjectBuilder();
      ReadObjectQuery query=new ReadObjectQuery();
      query.setReferenceClass(referenceClass);
      query.setSession((AbstractSession)readSession);
      object=objectBuilder.buildObject(query,xmlRow,null);
      xmlRow.resolveReferences(readSession,xmlUnmarshaller.getIDResolver());
    }
    String elementNamespaceUri=xmlRow.getDOM().getNamespaceURI();
    String elementLocalName=xmlRow.getDOM().getLocalName();
    if (elementLocalName == null) {
      elementLocalName=xmlRow.getDOM().getNodeName();
    }
    String elementPrefix=xmlRow.getDOM().getPrefix();
    return descriptor.wrapObjectInXMLRoot(object,elementNamespaceUri,elementLocalName,elementPrefix,xmlEncoding,xmlVersion,this.isResultAlwaysXMLRoot,true,xmlUnmarshaller);
  }
  finally {
    xmlUnmarshaller.getStringBuffer().reset();
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Convert the Oracle XMLDocument to the reference-class.
 */
public Object xmlToObject(DOMRecord xmlRow,Class referenceClass) throws XMLMarshalException {
  try {
    String xmlEncoding="String_Node_Str";
    String xmlVersion="String_Node_Str";
    try {
      Method getEncoding=PrivilegedAccessHelper.getMethod(xmlRow.getDocument().getClass(),"String_Node_Str",new Class[]{},true);
      Method getVersion=PrivilegedAccessHelper.getMethod(xmlRow.getDocument().getClass(),"String_Node_Str",new Class[]{},true);
      xmlEncoding=(String)PrivilegedAccessHelper.invokeMethod(getEncoding,xmlRow.getDocument(),new Object[]{});
      xmlVersion=(String)PrivilegedAccessHelper.invokeMethod(getVersion,xmlRow.getDocument(),new Object[]{});
    }
 catch (    Exception ex) {
    }
    XMLContext xmlContext=xmlUnmarshaller.getXMLContext();
    if (referenceClass != null && (XMLConversionManager.getDefaultJavaTypes().get(referenceClass) != null || CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(referenceClass) || CoreClassConstants.DURATION.isAssignableFrom(referenceClass))) {
      Object nodeVal;
      try {
        Text rootTxt=(Text)xmlRow.getDOM().getFirstChild();
        nodeVal=rootTxt.getNodeValue();
      }
 catch (      Exception ex) {
        nodeVal=null;
      }
      Object obj=((XMLConversionManager)xmlContext.getSession().getDatasourcePlatform().getConversionManager()).convertObject(nodeVal,referenceClass);
      Root xmlRoot=new XMLRoot();
      xmlRoot.setObject(obj);
      String lName=xmlRow.getDOM().getLocalName();
      if (lName == null) {
        lName=xmlRow.getDOM().getNodeName();
      }
      xmlRoot.setLocalName(lName);
      xmlRoot.setNamespaceURI(xmlRow.getDOM().getNamespaceURI());
      xmlRoot.setEncoding(xmlEncoding);
      xmlRoot.setVersion(xmlVersion);
      return xmlRoot;
    }
    Descriptor descriptor=null;
    CoreAbstractSession readSession=null;
    boolean shouldWrap=true;
    if (referenceClass == null) {
      QName rootQName=new QName(xmlRow.getNamespaceURI(),xmlRow.getLocalName());
      descriptor=xmlContext.getDescriptor(rootQName);
      if (null == descriptor) {
        String type=((Element)xmlRow.getDOM()).getAttributeNS(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,"String_Node_Str");
        if (null != type) {
          XPathFragment typeFragment=new XPathFragment(type);
          String namespaceURI=xmlRow.resolveNamespacePrefix(typeFragment.getPrefix());
          typeFragment.setNamespaceURI(namespaceURI);
          descriptor=xmlContext.getDescriptorByGlobalType(typeFragment);
        }
      }
 else       if (descriptor.getTables().size() == 1) {
        shouldWrap=false;
      }
      if (null == descriptor) {
        throw XMLMarshalException.noDescriptorWithMatchingRootElement(rootQName.toString());
      }
 else {
        readSession=xmlContext.getSession(descriptor.getJavaClass());
      }
    }
 else {
      readSession=xmlContext.getSession(referenceClass);
      descriptor=(Descriptor)readSession.getDescriptor(referenceClass);
      if (descriptor == null) {
        throw XMLMarshalException.descriptorNotFoundInProject(referenceClass.getName());
      }
    }
    Object object=null;
    if (null == xmlRow.getDOM().getAttributes().getNamedItemNS(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_NIL_ATTRIBUTE)) {
      xmlRow.setUnmarshaller(xmlUnmarshaller);
      xmlRow.setDocPresPolicy(xmlContext.getDocumentPreservationPolicy((AbstractSession)readSession));
      XMLObjectBuilder objectBuilder=(XMLObjectBuilder)descriptor.getObjectBuilder();
      ReadObjectQuery query=new ReadObjectQuery();
      query.setReferenceClass(referenceClass);
      query.setSession((AbstractSession)readSession);
      object=objectBuilder.buildObject(query,xmlRow,null);
      xmlRow.resolveReferences(readSession,xmlUnmarshaller.getIDResolver());
    }
    String elementNamespaceUri=xmlRow.getDOM().getNamespaceURI();
    String elementLocalName=xmlRow.getDOM().getLocalName();
    if (elementLocalName == null) {
      elementLocalName=xmlRow.getDOM().getNodeName();
    }
    String elementPrefix=xmlRow.getDOM().getPrefix();
    if (shouldWrap || descriptor.isResultAlwaysXMLRoot() || isResultAlwaysXMLRoot) {
      return descriptor.wrapObjectInXMLRoot(object,elementNamespaceUri,elementLocalName,elementPrefix,xmlEncoding,xmlVersion,this.isResultAlwaysXMLRoot,true,xmlUnmarshaller);
    }
 else {
      return object;
    }
  }
  finally {
    xmlUnmarshaller.getStringBuffer().reset();
  }
}