nus-yam/ex-repair huggingface dataset:
Program: 64135
Project: 64135
Buggy source:
/** 
 * @return true indicating that <i>MOXyJsonProvider</i> willbe used for the JSON binding if the media type is of the following  patterns *&#47;json or *&#47;*+json, and the type is not assignable from  any of the the following: <ul> <li>byte[]</li> <li>java.io.File</li> <li>java.lang.String</li> <li>javax.activation.DataSource</li> <li>javax.ws.rs.core.StreamingOutput</li> </ul>
 */
public boolean isWriteable(Class<?> type,Type genericType,Annotation[] annotations,MediaType mediaType){
  if (!supportsMediaType(mediaType)) {
    return false;
  }
 else   if (CoreClassConstants.APBYTE == type || CoreClassConstants.STRING == type) {
    return false;
  }
 else   if (File.class.isAssignableFrom(type)) {
    return false;
  }
 else   if (DataSource.class.isAssignableFrom(type)) {
    return false;
  }
 else   if (StreamingOutput.class.isAssignableFrom(type)) {
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * @return true indicating that <i>MOXyJsonProvider</i> willbe used for the JSON binding if the media type is of the following  patterns *&#47;json or *&#47;*+json, and the type is not assignable from  any of (or a Collection or JAXBElement of) the the following: <ul> <li>byte[]</li> <li>java.io.File</li> <li>java.lang.Object</li> <li>java.lang.String</li> <li>javax.activation.DataSource</li> <li>javax.ws.rs.core.StreamingOutput</li> </ul>
 */
public boolean isWriteable(Class<?> type,Type genericType,Annotation[] annotations,MediaType mediaType){
  if (!supportsMediaType(mediaType)) {
    return false;
  }
 else   if (CoreClassConstants.APBYTE == type || CoreClassConstants.STRING == type) {
    return false;
  }
 else   if (File.class.isAssignableFrom(type)) {
    return false;
  }
 else   if (DataSource.class.isAssignableFrom(type)) {
    return false;
  }
 else   if (StreamingOutput.class.isAssignableFrom(type)) {
    return false;
  }
 else   if (Object.class == type) {
    return false;
  }
 else   if (JAXBElement.class.isAssignableFrom(type)) {
    return isReadable(getDomainClass(genericType),null,annotations,mediaType);
  }
 else   if (Collection.class.isAssignableFrom(type)) {
    return isWriteable(getDomainClass(genericType),null,annotations,mediaType);
  }
 else {
    return true;
  }
}
Program: 64138
Project: 64138
Buggy source:
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  unmarshalRecord.removeNullCapableValue(this.nullCapableNodeValue);
  if (null != xmlChoiceMapping.getConverter()) {
    UnmarshalContext unmarshalContext=unmarshalRecord.getUnmarshalContext();
    unmarshalRecord.setUnmarshalContext(new ChoiceUnmarshalContext(unmarshalContext,xmlChoiceMapping));
    this.choiceElementNodeValue.endElement(xPathFragment,unmarshalRecord);
    unmarshalRecord.setUnmarshalContext(unmarshalContext);
  }
 else {
    this.choiceElementNodeValue.endElement(xPathFragment,unmarshalRecord);
  }
}

Fixed version (ground truth):
public void endElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord){
  if (null != xmlChoiceMapping.getConverter()) {
    UnmarshalContext unmarshalContext=unmarshalRecord.getUnmarshalContext();
    unmarshalRecord.setUnmarshalContext(new ChoiceUnmarshalContext(unmarshalContext,xmlChoiceMapping));
    this.choiceElementNodeValue.endElement(xPathFragment,unmarshalRecord);
    unmarshalRecord.setUnmarshalContext(unmarshalContext);
  }
 else {
    this.choiceElementNodeValue.endElement(xPathFragment,unmarshalRecord);
  }
}
Program: 64139
Project: 64139
Buggy source:
public boolean startElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts){
  unmarshalRecord.removeNullCapableValue(this.nullCapableNodeValue);
  return this.choiceElementNodeValue.startElement(xPathFragment,unmarshalRecord,atts);
}

Fixed version (ground truth):
public boolean startElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts){
  return this.choiceElementNodeValue.startElement(xPathFragment,unmarshalRecord,atts);
}
Program: 64140
Project: 64140
Buggy source:
/** 
 * The underlying choice element node value will handle attributes.
 */
public void attribute(UnmarshalRecord unmarshalRecord,String URI,String localName,String value){
  unmarshalRecord.removeNullCapableValue(this.nullCapableNodeValue);
  this.choiceElementNodeValue.attribute(unmarshalRecord,URI,localName,value);
}

Fixed version (ground truth):
/** 
 * The underlying choice element node value will handle attributes.
 */
public void attribute(UnmarshalRecord unmarshalRecord,String URI,String localName,String value){
  this.choiceElementNodeValue.attribute(unmarshalRecord,URI,localName,value);
}
Program: 64142
Project: 64142
Buggy source:
@Override public boolean equals(Object obj){
  if (null == obj) {
    return false;
  }
  try {
    DefaultNoNodeEmployee test=(DefaultNoNodeEmployee)obj;
    if (attribute != test.attribute || wasSetAttribute != test.wasSetAttribute) {
      return false;
    }
    if (elementString != test.elementString || wasSetElementString != test.wasSetElementString) {
      return false;
    }
    if (elementStringNillable != test.elementStringNillable || wasSetElementStringNillable != test.wasSetElementStringNillable) {
      return false;
    }
    if (elementPOJO != test.elementPOJO || wasSetElementPOJO != test.wasSetElementPOJO) {
      return false;
    }
    if (elementPOJONillable != test.elementPOJONillable || wasSetElementPOJONillable != test.wasSetElementPOJONillable) {
      return false;
    }
    if (reference != test.reference || wasSetReference != test.wasSetReference) {
      return false;
    }
    return true;
  }
 catch (  ClassCastException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (null == obj) {
    return false;
  }
  try {
    DefaultNoNodeEmployee test=(DefaultNoNodeEmployee)obj;
    if (any != test.any || wasSetAny != test.wasSetAny) {
      return false;
    }
    if (attribute != test.attribute || wasSetAttribute != test.wasSetAttribute) {
      return false;
    }
    if (choice != test.choice || wasSetChoice != test.wasSetChoice) {
      return false;
    }
    if (choiceList != test.choiceList || wasSetChoiceList != test.wasSetChoiceList) {
      return false;
    }
    if (elementString != test.elementString || wasSetElementString != test.wasSetElementString) {
      return false;
    }
    if (elementStringNillable != test.elementStringNillable || wasSetElementStringNillable != test.wasSetElementStringNillable) {
      return false;
    }
    if (elementPOJO != test.elementPOJO || wasSetElementPOJO != test.wasSetElementPOJO) {
      return false;
    }
    if (elementPOJONillable != test.elementPOJONillable || wasSetElementPOJONillable != test.wasSetElementPOJONillable) {
      return false;
    }
    if (reference != test.reference || wasSetReference != test.wasSetReference) {
      return false;
    }
    return true;
  }
 catch (  ClassCastException e) {
    return false;
  }
}
Program: 64143
Project: 64143
Buggy source:
/** 
 * Copy constructor
 */
protected Marshaller(Marshaller marshaller){
  this.charEscapeHandler=marshaller.getCharacterEscapeHandler();
  this.context=(CONTEXT)marshaller.getContext();
  this.encoding=marshaller.getEncoding();
  this.equalUsingIdenity=marshaller.isEqualUsingIdenity();
  this.formattedOutput=marshaller.isFormattedOutput();
  this.indentString=marshaller.getIndentString();
  this.mapper=(NAMESPACE_PREFIX_MAPPER)marshaller.getNamespacePrefixMapper();
  this.marshalListener=marshaller.getMarshalListener();
  if (marshaller.marshalProperties != null) {
    marshalProperties=new Properties();
    for (    Entry entry : marshalProperties.entrySet()) {
      marshalProperties.put(entry.getKey(),entry.getValue());
    }
  }
}

Fixed version (ground truth):
/** 
 * Copy constructor
 */
protected Marshaller(Marshaller marshaller){
  this.charEscapeHandler=marshaller.getCharacterEscapeHandler();
  this.context=(CONTEXT)marshaller.getContext();
  this.encoding=marshaller.getEncoding();
  this.equalUsingIdenity=marshaller.isEqualUsingIdenity();
  this.errorHandler=marshaller.getErrorHandler();
  this.formattedOutput=marshaller.isFormattedOutput();
  this.indentString=marshaller.getIndentString();
  this.mapper=(NAMESPACE_PREFIX_MAPPER)marshaller.getNamespacePrefixMapper();
  this.marshalListener=marshaller.getMarshalListener();
  if (marshaller.marshalProperties != null) {
    marshalProperties=new Properties();
    for (    Entry entry : marshalProperties.entrySet()) {
      marshalProperties.put(entry.getKey(),entry.getValue());
    }
  }
}
Program: 64144
Project: 64144
Buggy source:
/** 
 * Copy constructor
 */
protected XMLMarshaller(XMLMarshaller xmlMarshaller){
  super(xmlMarshaller);
  attachmentMarshaller=xmlMarshaller.getAttachmentMarshaller();
  attributePrefix=xmlMarshaller.getAttributePrefix();
  errorHandler=xmlMarshaller.getErrorHandler();
  fragment=xmlMarshaller.isFragment();
  includeRoot=xmlMarshaller.isIncludeRoot();
  marshalEmptyCollections=xmlMarshaller.isMarshalEmptyCollections();
  mediaType=(MEDIA_TYPE)xmlMarshaller.getMediaType();
  namespaceSeparator=xmlMarshaller.getNamespaceSeparator();
  noNamespaceSchemaLocation=xmlMarshaller.getNoNamespaceSchemaLocation();
  reduceAnyArrays=xmlMarshaller.isReduceAnyArrays();
  if (null != xmlMarshaller.getSchema()) {
    setSchema(xmlMarshaller.getSchema());
  }
  schemaLocation=xmlMarshaller.getSchemaLocation();
  valueWrapper=xmlMarshaller.getValueWrapper();
  xmlHeader=xmlMarshaller.getXmlHeader();
}

Fixed version (ground truth):
/** 
 * Copy constructor
 */
protected XMLMarshaller(XMLMarshaller xmlMarshaller){
  super(xmlMarshaller);
  attachmentMarshaller=xmlMarshaller.getAttachmentMarshaller();
  attributePrefix=xmlMarshaller.getAttributePrefix();
  fragment=xmlMarshaller.isFragment();
  includeRoot=xmlMarshaller.isIncludeRoot();
  marshalEmptyCollections=xmlMarshaller.isMarshalEmptyCollections();
  mediaType=(MEDIA_TYPE)xmlMarshaller.getMediaType();
  namespaceSeparator=xmlMarshaller.getNamespaceSeparator();
  noNamespaceSchemaLocation=xmlMarshaller.getNoNamespaceSchemaLocation();
  reduceAnyArrays=xmlMarshaller.isReduceAnyArrays();
  if (null != xmlMarshaller.getSchema()) {
    setSchema(xmlMarshaller.getSchema());
  }
  schemaLocation=xmlMarshaller.getSchemaLocation();
  valueWrapper=xmlMarshaller.getValueWrapper();
  xmlHeader=xmlMarshaller.getXmlHeader();
}
Program: 64148
Project: 64148
Buggy source:
public void afterContainmentMarshal(Object parent,Object child){
  if (null != marshaller) {
    XMLMarshalListener marshalListener=marshaller.getMarshalListener();
    if (null != marshalListener) {
      marshalListener.afterMarshal(child);
    }
  }
  setOwningObject(parent);
}

Fixed version (ground truth):
public void afterContainmentMarshal(Object parent,Object child){
  if (null != marshaller) {
    XMLMarshalListener marshalListener=marshaller.getMarshalListener();
    if (null != marshalListener) {
      try {
        marshalListener.afterMarshal(child);
      }
 catch (      EclipseLinkException e) {
        ErrorHandler errorHandler=marshaller.getErrorHandler();
        if (null == errorHandler) {
          throw e;
        }
 else {
          try {
            MarshalSAXParseException saxParseException=new MarshalSAXParseException(null,null,null,-1,-1,e,child);
            errorHandler.error(saxParseException);
          }
 catch (          SAXException saxParseException) {
            throw e;
          }
        }
      }
    }
  }
  setOwningObject(parent);
}
Program: 64149
Project: 64149
Buggy source:
public void beforeContainmentMarshal(Object child){
  if (null != marshaller) {
    XMLMarshalListener marshalListener=marshaller.getMarshalListener();
    if (null != marshalListener) {
      marshalListener.beforeMarshal(child);
    }
  }
  setOwningObject(child);
}

Fixed version (ground truth):
public void beforeContainmentMarshal(Object child){
  if (null != marshaller) {
    XMLMarshalListener marshalListener=marshaller.getMarshalListener();
    if (null != marshalListener) {
      try {
        marshalListener.beforeMarshal(child);
      }
 catch (      EclipseLinkException e) {
        ErrorHandler errorHandler=marshaller.getErrorHandler();
        if (null == errorHandler) {
          throw e;
        }
 else {
          try {
            MarshalSAXParseException saxParseException=new MarshalSAXParseException(null,null,null,-1,-1,e,child);
            errorHandler.error(saxParseException);
          }
 catch (          SAXException saxParseException) {
            throw e;
          }
        }
      }
    }
  }
  setOwningObject(child);
}
Program: 64151
Project: 64151
Buggy source:
private void handleException(SAXParseException exception,int severity) throws SAXException {
  ValidationEventLocatorImpl eventLocator=new ValidationEventLocatorImpl(exception);
  if (exception instanceof MarshalSAXParseException) {
    eventLocator.setObject(((MarshalSAXParseException)exception).getObject());
  }
  ValidationEvent event=new ValidationEventImpl(severity,exception.getLocalizedMessage(),eventLocator,exception);
  if (!eventHandler.handleEvent(event)) {
    throw exception;
  }
}

Fixed version (ground truth):
private void handleException(SAXParseException exception,int severity) throws SAXException {
  ValidationEventLocatorImpl eventLocator=new ValidationEventLocatorImpl(exception);
  if (exception instanceof MarshalSAXParseException) {
    eventLocator.setObject(((MarshalSAXParseException)exception).getObject());
  }
  Throwable linkedException=exception.getCause();
  if (linkedException instanceof EclipseLinkException) {
    linkedException=exception.getCause();
  }
  ValidationEvent event=new ValidationEventImpl(severity,exception.getLocalizedMessage(),eventLocator,linkedException);
  if (!eventHandler.handleEvent(event)) {
    if (linkedException instanceof EclipseLinkException) {
      throw (EclipseLinkException)linkedException;
    }
    throw exception;
  }
}
Program: 64152
Project: 64152
Buggy source:
public void beforeMarshal(Object obj){
  if (classBasedMarshalEvents != null) {
    MarshalCallback callback=(MarshalCallback)classBasedMarshalEvents.get(obj.getClass().getName());
    if (callback != null && callback.getBeforeMarshalCallback() != null) {
      try {
        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
          try {
            AccessController.doPrivileged(new PrivilegedMethodInvoker(callback.getBeforeMarshalCallback(),obj,new Object[]{marshaller}));
          }
 catch (          PrivilegedActionException ex) {
            if (ex.getCause() instanceof IllegalAccessException) {
              throw (IllegalAccessException)ex.getCause();
            }
            if (ex.getCause() instanceof InvocationTargetException) {
              throw (InvocationTargetException)ex.getCause();
            }
            throw (RuntimeException)ex.getCause();
          }
        }
 else {
          PrivilegedAccessHelper.invokeMethod(callback.getBeforeMarshalCallback(),obj,new Object[]{marshaller});
        }
      }
 catch (      Exception ex) {
      }
    }
  }
  if (listener != null) {
    if (obj instanceof Root) {
      obj=jaxbContext.createJAXBElementFromXMLRoot((Root)obj,((Root)obj).getDeclaredType());
    }
    listener.beforeMarshal(obj);
  }
}

Fixed version (ground truth):
public void beforeMarshal(Object obj){
  if (classBasedMarshalEvents != null) {
    MarshalCallback callback=(MarshalCallback)classBasedMarshalEvents.get(obj.getClass().getName());
    if (callback != null && callback.getBeforeMarshalCallback() != null) {
      try {
        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
          try {
            AccessController.doPrivileged(new PrivilegedMethodInvoker(callback.getBeforeMarshalCallback(),obj,new Object[]{marshaller}));
          }
 catch (          PrivilegedActionException ex) {
            if (ex.getCause() instanceof IllegalAccessException) {
              throw (IllegalAccessException)ex.getCause();
            }
            if (ex.getCause() instanceof InvocationTargetException) {
              throw (InvocationTargetException)ex.getCause();
            }
            throw (RuntimeException)ex.getCause();
          }
        }
 else {
          PrivilegedAccessHelper.invokeMethod(callback.getBeforeMarshalCallback(),obj,new Object[]{marshaller});
        }
      }
 catch (      Exception ex) {
        throw XMLMarshalException.marshalException(ex);
      }
    }
  }
  if (listener != null) {
    if (obj instanceof Root) {
      obj=jaxbContext.createJAXBElementFromXMLRoot((Root)obj,((Root)obj).getDeclaredType());
    }
    listener.beforeMarshal(obj);
  }
}
Program: 64153
Project: 64153
Buggy source:
public void afterMarshal(Object obj){
  if (classBasedMarshalEvents != null) {
    MarshalCallback callback=(MarshalCallback)classBasedMarshalEvents.get(obj.getClass().getName());
    if (callback != null && callback.getAfterMarshalCallback() != null) {
      try {
        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
          try {
            AccessController.doPrivileged(new PrivilegedMethodInvoker(callback.getAfterMarshalCallback(),obj,new Object[]{marshaller}));
          }
 catch (          PrivilegedActionException ex) {
            if (ex.getCause() instanceof IllegalAccessException) {
              throw (IllegalAccessException)ex.getCause();
            }
            if (ex.getCause() instanceof InvocationTargetException) {
              throw (InvocationTargetException)ex.getCause();
            }
            throw (RuntimeException)ex.getCause();
          }
        }
 else {
          PrivilegedAccessHelper.invokeMethod(callback.getAfterMarshalCallback(),obj,new Object[]{marshaller});
        }
      }
 catch (      Exception ex) {
      }
    }
  }
  if (listener != null) {
    if (obj instanceof Root) {
      obj=jaxbContext.createJAXBElementFromXMLRoot((Root)obj,((Root)obj).getDeclaredType());
    }
    listener.afterMarshal(obj);
  }
}

Fixed version (ground truth):
public void afterMarshal(Object obj){
  if (classBasedMarshalEvents != null) {
    MarshalCallback callback=(MarshalCallback)classBasedMarshalEvents.get(obj.getClass().getName());
    if (callback != null && callback.getAfterMarshalCallback() != null) {
      try {
        if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
          try {
            AccessController.doPrivileged(new PrivilegedMethodInvoker(callback.getAfterMarshalCallback(),obj,new Object[]{marshaller}));
          }
 catch (          PrivilegedActionException ex) {
            if (ex.getCause() instanceof IllegalAccessException) {
              throw (IllegalAccessException)ex.getCause();
            }
            if (ex.getCause() instanceof InvocationTargetException) {
              throw (InvocationTargetException)ex.getCause();
            }
            throw (RuntimeException)ex.getCause();
          }
        }
 else {
          PrivilegedAccessHelper.invokeMethod(callback.getAfterMarshalCallback(),obj,new Object[]{marshaller});
        }
      }
 catch (      Exception ex) {
        throw XMLMarshalException.marshalException(ex);
      }
    }
  }
  if (listener != null) {
    if (obj instanceof Root) {
      obj=jaxbContext.createJAXBElementFromXMLRoot((Root)obj,((Root)obj).getDeclaredType());
    }
    listener.afterMarshal(obj);
  }
}
Program: 64156
Project: 64156
Buggy source:
/** 
 * Execute <tt>DELETE</tt> operation on the database
 * @param xrService parent <code>XRService</code> that owns this <code>Operation</code>
 * @param invocation contains runtime argument values to be bound to the list of{@link Parameter}'s.
 * @return  result - can be <code>null</code> if the underlying <tt>DELETE</tt> operation on thedatabase does not return a value
 * @see  {@link Operation}
 */
@Override public Object invoke(XRServiceAdapter xrService,Invocation invocation){
  ReadObjectQuery roq=(ReadObjectQuery)classDescriptor.getQueryManager().getQuery(PK_QUERYNAME);
  List queryArguments=roq.getArguments();
  int queryArgumentsSize=queryArguments.size();
  Vector executeArguments=new NonSynchronizedVector();
  for (int i=0; i < queryArgumentsSize; i++) {
    String argName=(String)queryArguments.get(i);
    executeArguments.add(invocation.getParameter(argName));
  }
  UnitOfWork uow=xrService.getORSession().acquireUnitOfWork();
  Object toBeDeleted=uow.executeQuery(roq,executeArguments);
  if (toBeDeleted != null) {
    uow.deleteObject(toBeDeleted);
    uow.commit();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Execute <tt>DELETE</tt> operation on the database
 * @param xrService parent <code>XRService</code> that owns this <code>Operation</code>
 * @param invocation contains runtime argument values to be bound to the list of{@link Parameter}'s.
 * @return  result - can be <code>null</code> if the underlying <tt>DELETE</tt> operation on thedatabase does not return a value
 * @see  {@link Operation}
 */
@SuppressWarnings("String_Node_Str") @Override public Object invoke(XRServiceAdapter xrService,Invocation invocation){
  DatabaseQuery query=classDescriptor.getQueryManager().getQuery(PK_QUERYNAME + UNDERSCORE_STR + descriptorName+ TYPE_STR);
  if (query instanceof JPAQuery) {
    query=((JPAQuery)query).processSQLQuery(xrService.getORSession().getActiveSession());
  }
  UnitOfWork uow=xrService.getORSession().acquireUnitOfWork();
  Object toBeDeleted;
  if (query.getArguments().size() == 0) {
    int idx=0;
    for (    Parameter param : getParameters()) {
      query.addArgument(Integer.toString(++idx),Util.SCHEMA_2_CLASS.get(param.getType()));
      query.addArgumentValue(invocation.getParameter(param.getName()));
    }
    toBeDeleted=uow.executeQuery(query);
  }
 else {
    List queryArguments=query.getArguments();
    int queryArgumentsSize=queryArguments.size();
    Vector executeArguments=new NonSynchronizedVector();
    for (int i=0; i < queryArgumentsSize; i++) {
      String argName=(String)queryArguments.get(i);
      executeArguments.add(invocation.getParameter(argName));
    }
    toBeDeleted=uow.executeQuery(query,executeArguments);
  }
  if (!isCollection() && toBeDeleted instanceof Vector) {
    if (((Vector)toBeDeleted).isEmpty()) {
      toBeDeleted=null;
    }
 else {
      toBeDeleted=((Vector)toBeDeleted).firstElement();
    }
  }
  if (toBeDeleted != null) {
    uow.deleteObject(toBeDeleted);
    uow.commit();
  }
  return null;
}
Program: 64157
Project: 64157
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void initialize(XRServiceAdapter xrService,QueryOperation queryOperation){
  if (descriptor != null) {
    ClassDescriptor cd=xrService.getORSession().getProject().getDescriptorForAlias(descriptor);
    databaseQuery=cd.getQueryManager().getQuery(name);
  }
 else {
    databaseQuery=xrService.getORSession().getQuery(name);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void initialize(XRServiceAdapter xrService,QueryOperation queryOperation){
  if (descriptor != null) {
    ClassDescriptor cd=xrService.getORSession().getProject().getDescriptorForAlias(descriptor);
    databaseQuery=cd.getQueryManager().getQuery(name);
  }
 else {
    databaseQuery=xrService.getORSession().getQuery(name);
    if (databaseQuery == null) {
      for (      DatabaseQuery q : xrService.getORSession().getJPAQueries()) {
        if (q.getName().equals(name)) {
          databaseQuery=q;
          break;
        }
      }
    }
  }
}
Program: 64158
Project: 64158
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public void validate(XRServiceAdapter xrService,QueryOperation queryOperation){
  if (descriptor != null) {
    if (!xrService.getORSession().getProject().getAliasDescriptors().containsKey(descriptor)) {
      throw DBWSException.couldNotLocateDescriptorForOperation(descriptor,getName());
    }
    ClassDescriptor cd=xrService.getORSession().getProject().getDescriptorForAlias(descriptor);
    if (cd.getQueryManager().getQuery(name) == null) {
      throw DBWSException.couldNotLocateQueryForDescriptor(name,descriptor);
    }
  }
 else   if (xrService.getORSession().getQuery(name) == null) {
    throw DBWSException.couldNotLocateQueryForSession(name,xrService.getORSession().getName());
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void validate(XRServiceAdapter xrService,QueryOperation queryOperation){
  if (descriptor != null) {
    if (!xrService.getORSession().getProject().getAliasDescriptors().containsKey(descriptor)) {
      throw DBWSException.couldNotLocateDescriptorForOperation(descriptor,getName());
    }
    ClassDescriptor cd=xrService.getORSession().getProject().getDescriptorForAlias(descriptor);
    if (cd.getQueryManager().getQuery(name) == null) {
      boolean foundQuery=false;
      for (      DatabaseQuery q : xrService.getORSession().getProject().getJPAQueries()) {
        if (q.getName().equals(name)) {
          foundQuery=true;
          cd.getQueryManager().addQuery(name,q);
          break;
        }
      }
      if (!foundQuery) {
        throw DBWSException.couldNotLocateQueryForDescriptor(name,descriptor);
      }
    }
  }
 else   if (xrService.getORSession().getQuery(name) == null) {
    boolean foundQuery=false;
    for (    DatabaseQuery q : xrService.getORSession().getJPAQueries()) {
      if (q.getName().equals(name)) {
        foundQuery=true;
        break;
      }
    }
    if (!foundQuery) {
      throw DBWSException.couldNotLocateQueryForSession(name,xrService.getORSession().getName());
    }
  }
}
Program: 64160
Project: 64160
Buggy source:
private void setAttributeValue(Object object,UnmarshalRecord unmarshalRecord){
  object=xmlCompositeObjectMapping.convertDataValueToObjectValue(object,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
  unmarshalRecord.setAttributeValue(object,xmlCompositeObjectMapping);
  InverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
  if (null != inverseReferenceMapping) {
    if (inverseReferenceMapping.getContainerPolicy() == null) {
      Object currentValue=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (!isInverseReference || (currentValue == null && isInverseReference)) {
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,unmarshalRecord.getCurrentObject());
      }
    }
 else {
      Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (backpointerContainer == null) {
        backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,backpointerContainer);
      }
      inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
}

Fixed version (ground truth):
private void setAttributeValue(Object object,UnmarshalRecord unmarshalRecord){
  InverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
  if (null != inverseReferenceMapping) {
    if (inverseReferenceMapping.getContainerPolicy() == null) {
      Object currentValue=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (!isInverseReference || (currentValue == null && isInverseReference)) {
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,unmarshalRecord.getCurrentObject());
      }
    }
 else {
      Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (backpointerContainer == null) {
        backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,backpointerContainer);
      }
      inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
  object=xmlCompositeObjectMapping.convertDataValueToObjectValue(object,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
  unmarshalRecord.setAttributeValue(object,xmlCompositeObjectMapping);
}
Program: 64161
Project: 64161
Buggy source:
public boolean equals(Object object,boolean ignorePredicate){
  if (null == object) {
    return false;
  }
 else   if (this == object) {
    return true;
  }
  try {
    XPathFragment xPathFragment=(XPathFragment)object;
    if (nameIsText && xPathFragment.nameIsText) {
      return true;
    }
    if (nameIsText != xPathFragment.nameIsText) {
      return false;
    }
    if ((null == localName && null != xPathFragment.localName) || (null != localName && null == xPathFragment.localName)) {
      return false;
    }
    if (null != localName && !localName.equals(xPathFragment.localName)) {
      return false;
    }
    if (namespaceAware && xPathFragment.isNamespaceAware()) {
      if ((null == namespaceURI && null != xPathFragment.namespaceURI) || (null != namespaceURI && null == xPathFragment.namespaceURI)) {
        return false;
      }
      if (null != namespaceURI && !namespaceURI.equals(xPathFragment.namespaceURI)) {
        return false;
      }
    }
    if (indexValue != xPathFragment.indexValue) {
      return false;
    }
    if (!ignorePredicate) {
      if (null == predicate && null != xPathFragment.predicate) {
        return false;
      }
      if (null != predicate && !predicate.equals(xPathFragment.predicate)) {
        return false;
      }
    }
  }
 catch (  ClassCastException e) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean equals(Object object,boolean ignorePredicate){
  if (null == object) {
    return false;
  }
 else   if (this == object) {
    return true;
  }
  try {
    XPathFragment xPathFragment=(XPathFragment)object;
    if (hasAttribute && !xPathFragment.hasAttribute) {
      return false;
    }
    if (nameIsText && xPathFragment.nameIsText) {
      return true;
    }
    if (nameIsText != xPathFragment.nameIsText) {
      return false;
    }
    if ((null == localName && null != xPathFragment.localName) || (null != localName && null == xPathFragment.localName)) {
      return false;
    }
    if (null != localName && !localName.equals(xPathFragment.localName)) {
      return false;
    }
    if (namespaceAware && xPathFragment.isNamespaceAware()) {
      if ((null == namespaceURI && null != xPathFragment.namespaceURI) || (null != namespaceURI && null == xPathFragment.namespaceURI)) {
        return false;
      }
      if (null != namespaceURI && !namespaceURI.equals(xPathFragment.namespaceURI)) {
        return false;
      }
    }
    if (indexValue != xPathFragment.indexValue) {
      return false;
    }
    if (!ignorePredicate) {
      if (null == predicate && null != xPathFragment.predicate) {
        return false;
      }
      if (null != predicate && !predicate.equals(xPathFragment.predicate)) {
        return false;
      }
    }
  }
 catch (  ClassCastException e) {
    return false;
  }
  return true;
}
Program: 64165
Project: 64165
Buggy source:
/** 
 * <p>INTERNAL:
 */
@SuppressWarnings("String_Node_Str") protected static void alignDescriptorAliases(Project oxProject,Project orProject,XRDynamicClassLoader xrdcl){
  if (oxProject.getAliasDescriptors() != null) {
    Map<String,XMLDescriptor> oxAliases=new HashMap<String,XMLDescriptor>();
    for (    Object key : oxProject.getAliasDescriptors().keySet()) {
      String alias=key.toString();
      XMLDescriptor xdesc=(XMLDescriptor)oxProject.getAliasDescriptors().get(alias);
      ClassDescriptor odesc=null;
      if (orProject.getAliasDescriptors() != null && (odesc=(ClassDescriptor)orProject.getAliasDescriptors().get(alias)) == null) {
        alias=Character.toLowerCase(alias.charAt(0)) + (alias.length() > 1 ? alias.substring(1) : EMPTY_STR);
      }
      String defaultRootElement=xdesc.getDefaultRootElement();
      String proposedAlias=defaultRootElement;
      if (defaultRootElement.endsWith(TYPE_STR)) {
        proposedAlias=defaultRootElement.substring(0,defaultRootElement.lastIndexOf(TYPE_STR));
      }
      proposedAlias=proposedAlias.toLowerCase();
      xdesc.setAlias(proposedAlias);
      oxAliases.put(proposedAlias,xdesc);
      if (odesc != null) {
        orProject.getAliasDescriptors().remove(alias);
        odesc.setAlias(proposedAlias);
        odesc.convertClassNamesToClasses(xrdcl);
        orProject.getAliasDescriptors().put(proposedAlias,odesc);
      }
    }
    oxProject.setAliasDescriptors(oxAliases);
  }
}

Fixed version (ground truth):
/** 
 * <p>INTERNAL: Make sure OX  and OR descriptor aliases match - this is necessary as at runtime we typically lookup an OX descriptor, then access the related OR descriptor by alias.
 */
@SuppressWarnings("String_Node_Str") protected static void alignDescriptorAliases(Project oxProject,Project orProject,XRDynamicClassLoader xrdcl){
  if (oxProject.getAliasDescriptors() != null) {
    Map<String,XMLDescriptor> oxAliases=new HashMap<String,XMLDescriptor>();
    for (    Object key : oxProject.getAliasDescriptors().keySet()) {
      String alias=key.toString();
      XMLDescriptor xdesc=(XMLDescriptor)oxProject.getAliasDescriptors().get(alias);
      ClassDescriptor odesc=null;
      if (orProject.getAliasDescriptors() != null && (odesc=(ClassDescriptor)orProject.getAliasDescriptors().get(alias)) == null) {
        alias=Character.toLowerCase(alias.charAt(0)) + (alias.length() > 1 ? alias.substring(1) : EMPTY_STR);
      }
      String defaultRootElement=xdesc.getDefaultRootElement();
      String proposedAlias=defaultRootElement;
      if (defaultRootElement.endsWith(TYPE_STR)) {
        proposedAlias=defaultRootElement.substring(0,defaultRootElement.lastIndexOf(TYPE_STR));
      }
      proposedAlias=proposedAlias.toLowerCase();
      xdesc.setAlias(proposedAlias);
      oxAliases.put(proposedAlias,xdesc);
      if (odesc != null) {
        orProject.getAliasDescriptors().remove(alias);
        odesc.setAlias(proposedAlias);
        odesc.convertClassNamesToClasses(xrdcl);
        orProject.getAliasDescriptors().put(proposedAlias,odesc);
      }
    }
    oxProject.setAliasDescriptors(oxAliases);
  }
}
Program: 64169
Project: 64169
Buggy source:
public XMLCompositeCollectionMappingNodeValue(CompositeCollectionMapping xmlCompositeCollectionMapping){
  super();
  this.xmlCompositeCollectionMapping=xmlCompositeCollectionMapping;
}

Fixed version (ground truth):
public XMLCompositeCollectionMappingNodeValue(CompositeCollectionMapping xmlCompositeCollectionMapping,boolean isInverse){
  this(xmlCompositeCollectionMapping);
  this.isInverseReference=isInverse;
}
Program: 64170
Project: 64170
Buggy source:
private void setAttributeValue(Object object,UnmarshalRecord unmarshalRecord){
  object=xmlCompositeObjectMapping.convertDataValueToObjectValue(object,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
  unmarshalRecord.setAttributeValue(object,xmlCompositeObjectMapping);
  InverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
  if (null != inverseReferenceMapping) {
    if (inverseReferenceMapping.getContainerPolicy() == null) {
      inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,unmarshalRecord.getCurrentObject());
    }
 else {
      Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (backpointerContainer == null) {
        backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,backpointerContainer);
      }
      inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
}

Fixed version (ground truth):
private void setAttributeValue(Object object,UnmarshalRecord unmarshalRecord){
  object=xmlCompositeObjectMapping.convertDataValueToObjectValue(object,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
  unmarshalRecord.setAttributeValue(object,xmlCompositeObjectMapping);
  InverseReferenceMapping inverseReferenceMapping=xmlCompositeObjectMapping.getInverseReferenceMapping();
  if (null != inverseReferenceMapping) {
    if (inverseReferenceMapping.getContainerPolicy() == null) {
      Object currentValue=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (!isInverseReference || (currentValue == null && isInverseReference)) {
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,unmarshalRecord.getCurrentObject());
      }
    }
 else {
      Object backpointerContainer=inverseReferenceMapping.getAttributeAccessor().getAttributeValueFromObject(object);
      if (backpointerContainer == null) {
        backpointerContainer=inverseReferenceMapping.getContainerPolicy().containerInstance();
        inverseReferenceMapping.getAttributeAccessor().setAttributeValueInObject(object,backpointerContainer);
      }
      inverseReferenceMapping.getContainerPolicy().addInto(unmarshalRecord.getCurrentObject(),backpointerContainer,unmarshalRecord.getSession());
    }
  }
}
Program: 64171
Project: 64171
Buggy source:
public boolean marshal(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (xmlCompositeObjectMapping.isReadOnly()) {
    return false;
  }
  Object objectValue=marshalContext.getAttributeValue(object,xmlCompositeObjectMapping);
  return this.marshalSingleValue(xPathFragment,marshalRecord,object,objectValue,session,namespaceResolver,marshalContext);
}

Fixed version (ground truth):
public boolean marshal(XPathFragment xPathFragment,MarshalRecord marshalRecord,Object object,CoreAbstractSession session,NamespaceResolver namespaceResolver,MarshalContext marshalContext){
  if (xmlCompositeObjectMapping.isReadOnly()) {
    return false;
  }
  int size=marshalRecord.getCycleDetectionStack().size();
  Object objectValue=marshalContext.getAttributeValue(object,xmlCompositeObjectMapping);
  if ((isInverseReference || xmlCompositeObjectMapping.getInverseReferenceMapping() != null) && objectValue != null && size >= 2) {
    Object owner=marshalRecord.getCycleDetectionStack().get(size - 2);
    if (owner.equals(objectValue)) {
      return false;
    }
  }
  return this.marshalSingleValue(xPathFragment,marshalRecord,object,objectValue,session,namespaceResolver,marshalContext);
}
Program: 64172
Project: 64172
Buggy source:
public XMLCompositeObjectMappingNodeValue(CompositeObjectMapping xmlCompositeObjectMapping){
  this.xmlCompositeObjectMapping=xmlCompositeObjectMapping;
}

Fixed version (ground truth):
public XMLCompositeObjectMappingNodeValue(CompositeObjectMapping xmlCompositeObjectMapping,boolean isInverse){
  this(xmlCompositeObjectMapping);
  isInverseReference=isInverse;
}
Program: 64175
Project: 64175
Buggy source:
@Override public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  setFields(new Vector<DatabaseField>());
}

Fixed version (ground truth):
@Override public void initialize(AbstractSession session) throws DescriptorException {
  super.initialize(session);
  setFields(new Vector<DatabaseField>());
  if (inlineMapping != null) {
    inlineMapping.initialize(session);
  }
}
Program: 64176
Project: 64176
Buggy source:
@Override public int size(){
  return data.length;
}

Fixed version (ground truth):
@Override public int size(){
  return currentIndex;
}
Program: 64178
Project: 64178
Buggy source:
protected void endElementProcessText(UnmarshalRecord unmarshalRecord,XMLConverterMapping converter,XPathFragment xPathFragment,Object collection){
  Object value=unmarshalRecord.getCharacters().toString();
  unmarshalRecord.resetStringBuffer();
  if (!Constants.EMPTY_STRING.equals(value)) {
    QName qname=unmarshalRecord.getTypeQName();
    if (qname != null) {
      if (qname.equals(Constants.QNAME_QNAME)) {
        value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).buildQNameFromString((String)value,unmarshalRecord);
      }
 else {
        Class theClass=getClassForQName(qname);
        if (theClass != null) {
          value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(value,theClass,qname);
        }
      }
    }
    value=converter.convertDataValueToObjectValue(value,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    setOrAddAttributeValue(unmarshalRecord,value,xPathFragment,collection);
  }
}

Fixed version (ground truth):
protected void endElementProcessText(UnmarshalRecord unmarshalRecord,XMLConverterMapping converter,XPathFragment xPathFragment,Object collection){
  Object value=unmarshalRecord.getCharacters().toString();
  unmarshalRecord.resetStringBuffer();
  if (!unmarshalRecord.isNil()) {
    QName qname=unmarshalRecord.getTypeQName();
    if (qname == null) {
      if (Constants.EMPTY_STRING.equals(value)) {
        value=null;
      }
    }
 else {
      if (qname.equals(Constants.QNAME_QNAME)) {
        value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).buildQNameFromString((String)value,unmarshalRecord);
      }
 else {
        Class theClass=getClassForQName(qname);
        if (theClass != null) {
          value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(value,theClass,qname);
        }
      }
    }
    value=converter.convertDataValueToObjectValue(value,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    setOrAddAttributeValue(unmarshalRecord,value,xPathFragment,collection);
  }
}
Program: 64179
Project: 64179
Buggy source:
@Override protected void processEmptyElement() throws SAXException {
  getEvents().remove(0);
  nodeValue.getContainerPolicy().addInto(null,getParent().getContainerInstance(nodeValue),getParent().getSession());
  executeEvents(getParent());
}

Fixed version (ground truth):
@Override protected void processEmptyElement() throws SAXException {
  getEvents().remove(0);
  executeEvents(getParent());
}
Program: 64180
Project: 64180
Buggy source:
@Override protected void processEmptyElement() throws SAXException {
  throw XMLMarshalException.noDescriptorFound(mapping);
}

Fixed version (ground truth):
@Override protected void processEmptyElement() throws SAXException {
  processSimpleElement();
}
Program: 64182
Project: 64182
Buggy source:
protected void endElementProcessText(UnmarshalRecord unmarshalRecord,XMLConverterMapping converter,XPathFragment xPathFragment,Object collection){
  Object value=unmarshalRecord.getCharacters().toString();
  unmarshalRecord.resetStringBuffer();
  if (!Constants.EMPTY_STRING.equals(value)) {
    QName qname=unmarshalRecord.getTypeQName();
    if (qname != null) {
      if (qname.equals(Constants.QNAME_QNAME)) {
        value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).buildQNameFromString((String)value,unmarshalRecord);
      }
 else {
        Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(qname);
        if (theClass != null) {
          value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(value,theClass,qname);
        }
      }
    }
    value=converter.convertDataValueToObjectValue(value,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    setOrAddAttributeValue(unmarshalRecord,value,xPathFragment,collection);
  }
}

Fixed version (ground truth):
protected void endElementProcessText(UnmarshalRecord unmarshalRecord,XMLConverterMapping converter,XPathFragment xPathFragment,Object collection){
  Object value=unmarshalRecord.getCharacters().toString();
  unmarshalRecord.resetStringBuffer();
  if (!Constants.EMPTY_STRING.equals(value)) {
    QName qname=unmarshalRecord.getTypeQName();
    if (qname != null) {
      if (qname.equals(Constants.QNAME_QNAME)) {
        value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).buildQNameFromString((String)value,unmarshalRecord);
      }
 else {
        Class theClass=getClassForQName(qname);
        if (theClass != null) {
          value=((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).convertObject(value,theClass,qname);
        }
      }
    }
    value=converter.convertDataValueToObjectValue(value,unmarshalRecord.getSession(),unmarshalRecord.getUnmarshaller());
    setOrAddAttributeValue(unmarshalRecord,value,xPathFragment,collection);
  }
}
Program: 64183
Project: 64183
Buggy source:
/** 
 * INTERNAL:
 */
public QName getSchemaTypeForValue(Object value,CoreAbstractSession session){
  if (leafElementType != null) {
    return leafElementType;
  }
 else   if (isTypedTextField) {
    return getXMLType(value.getClass());
  }
  return schemaType;
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public QName getSchemaTypeForValue(Object value,CoreAbstractSession session){
  if (leafElementType != null) {
    return leafElementType;
  }
 else   if (isTypedTextField) {
    if (CoreClassConstants.XML_GREGORIAN_CALENDAR.isAssignableFrom(value.getClass())) {
      return ((XMLGregorianCalendar)value).getXMLSchemaType();
    }
 else     if (CoreClassConstants.DURATION.isAssignableFrom(value.getClass())) {
      return getXMLType(CoreClassConstants.DURATION);
    }
    return getXMLType(value.getClass());
  }
  return schemaType;
}
Program: 64184
Project: 64184
Buggy source:
public void setUp() throws Exception {
  Class[] classesToBeBound=new Class[]{TestObject.class};
  jaxbContext=JAXBContextFactory.createContext(classesToBeBound,null);
  jaxbIntrospector=jaxbContext.createJAXBIntrospector();
}

Fixed version (ground truth):
public void setUp() throws Exception {
  Class[] classesToBeBound=new Class[]{TestObject.class,ElementDeclObject.class,ObjectFactory.class};
  jaxbContext=JAXBContextFactory.createContext(classesToBeBound,null);
  jaxbIntrospector=jaxbContext.createJAXBIntrospector();
}
Program: 64185
Project: 64185
Buggy source:
public boolean isElement(Object obj){
  if (obj instanceof JAXBElement) {
    return true;
  }
  try {
    Session session=context.getSession(obj);
    if (session == null) {
      return false;
    }
    Descriptor descriptor=(Descriptor)session.getDescriptor(obj);
    if (descriptor == null) {
      return false;
    }
    return descriptor.getDefaultRootElement().length() != 0;
  }
 catch (  XMLMarshalException e) {
    return false;
  }
}

Fixed version (ground truth):
public boolean isElement(Object obj){
  if (obj instanceof JAXBElement) {
    return true;
  }
  try {
    Session session=context.getSession(obj);
    if (session == null) {
      return false;
    }
    Descriptor descriptor=(Descriptor)session.getDescriptor(obj);
    if (descriptor == null) {
      return false;
    }
    return descriptor.getDefaultRootElementField() != null;
  }
 catch (  XMLMarshalException e) {
    return false;
  }
}