Program: 68018
Project: 68018
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)((SDOType)getContainingType()).getXmlDescriptor().getMappingForAttributeName(getName());
      if (mapping != null) {
        ((SDOType)getContainingType()).getXmlDescriptor().getMappings().remove(mapping);
      }
      if ((indexToAdd > -1) && (indexToAdd < ((SDOType)getContainingType()).getXmlDescriptor().getMappings().size())) {
        ((SDOType)getContainingType()).getXmlDescriptor().getMappings().add(indexToAdd,xmlMapping);
      }
 else {
        ((SDOType)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=((SDOType)getContainingType()).getXmlDescriptor();
      xmlMapping.setDescriptor(containingDescriptor);
      XMLMapping mapping=(XMLMapping)((SDOType)getContainingType()).getXmlDescriptor().getMappingForAttributeName(getName());
      if (mapping != null) {
        ((SDOType)getContainingType()).getXmlDescriptor().getMappings().remove(mapping);
      }
      if (indexToAdd == -1) {
        ((SDOType)getContainingType()).getXmlDescriptor().getMappings().add(xmlMapping);
      }
 else {
        SDOType containingType=(SDOType)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) {
          ((SDOType)getContainingType()).getXmlDescriptor().getMappings().add(xmlMapping);
        }
      }
    }
  }
}