Program: 67101
Project: 67101
Buggy source:
/** 
 * INTERNAL:
 */
public void addMappingToOwner(boolean sdoMethodAttributeAccessor,int indexToAdd){
  if (xmlMapping != null) {
    if (sdoMethodAttributeAccessor) {
      SDOMethodAttributeAccessor accessor=null;
      if (this.getType().isDataType()) {
        Class theClass=getType().getInstanceClass();
        accessor=new SDOMethodAttributeAccessor(this,theClass);
      }
 else {
        accessor=new SDOMethodAttributeAccessor(this);
      }
      xmlMapping.setAttributeAccessor(accessor);
    }
    if ((getContainingType() != null) && !getContainingType().isDataType()) {
      ClassDescriptor containingDescriptor=((SDOType)getContainingType()).getXmlDescriptor();
      xmlMapping.setDescriptor(containingDescriptor);
      XMLMapping mapping=(XMLMapping)getContainingType().getXmlDescriptor().getMappingForAttributeName(getName());
      if (mapping != null) {
        getContainingType().getXmlDescriptor().getMappings().remove(mapping);
      }
      if (indexToAdd == -1) {
        getContainingType().getXmlDescriptor().getMappings().add(xmlMapping);
      }
 else {
        SDOType containingType=getContainingType();
        Vector<DatabaseMapping> mappings=containingType.getXmlDescriptor().getMappings();
        boolean added=false;
        for (int i=0; i < mappings.size(); i++) {
          DatabaseMapping next=mappings.get(i);
          SDOProperty associatedProperty=containingType.getProperty(next.getAttributeName());
          if (associatedProperty != null && indexToAdd < associatedProperty.getIndexInType()) {
            mappings.add(i,xmlMapping);
            added=true;
            break;
          }
        }
        if (!added) {
          getContainingType().getXmlDescriptor().getMappings().add(xmlMapping);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public void addMappingToOwner(boolean sdoMethodAttributeAccessor,int indexToAdd){
  if (xmlMapping != null) {
    if (sdoMethodAttributeAccessor) {
      SDOMethodAttributeAccessor accessor=null;
      if (this.getType().isDataType()) {
        Class theClass=getType().getInstanceClass();
        accessor=new SDOMethodAttributeAccessor(this,theClass);
      }
 else {
        accessor=new SDOMethodAttributeAccessor(this);
      }
      xmlMapping.setAttributeAccessor(accessor);
    }
    if ((getContainingType() != null) && !getContainingType().isDataType()) {
      ClassDescriptor containingDescriptor=getContainingType().getXmlDescriptor();
      xmlMapping.setDescriptor(containingDescriptor);
      XMLMapping mapping=(XMLMapping)getContainingType().getXmlDescriptor().getMappingForAttributeName(getName());
      if (mapping != null) {
        getContainingType().getXmlDescriptor().getMappings().remove(mapping);
      }
      if (indexToAdd == -1) {
        getContainingType().getXmlDescriptor().getMappings().add(xmlMapping);
      }
 else {
        SDOType containingType=getContainingType();
        Vector<DatabaseMapping> mappings=containingType.getXmlDescriptor().getMappings();
        boolean added=false;
        for (int i=0; i < mappings.size(); i++) {
          DatabaseMapping next=mappings.get(i);
          SDOProperty associatedProperty=containingType.getProperty(next.getAttributeName());
          if (associatedProperty != null && indexToAdd < associatedProperty.getIndexInType()) {
            mappings.add(i,xmlMapping);
            added=true;
            break;
          }
        }
        if (!added) {
          getContainingType().getXmlDescriptor().getMappings().add(xmlMapping);
        }
      }
    }
  }
}