Program: 67389
Project: 67389
Buggy source:
/** 
 * INTERNAL: Use the key to create a EclipseLink primary key Vector. If the key is simple (direct mapped) then just add it to a vector, otherwise must go through the inefficient process of copying the key into the bean and extracting the key from the bean.
 * @param key Object the primary key to use for creating the vector
 * @return Vector
 */
public Vector createPkVectorFromKey(Object key,AbstractSession session){
  KeyElementAccessor[] pkElementArray=this.getKeyClassFields(key.getClass());
  Vector pkVector=new NonSynchronizedVector(pkElementArray.length);
  for (int index=0; index < pkElementArray.length; index++) {
    DatabaseMapping mapping=pkElementArray[index].getMapping();
    Object fieldValue=null;
    if (mapping.isDirectToFieldMapping()) {
      fieldValue=((AbstractDirectMapping)mapping).getFieldValue(pkElementArray[index].getValue(key,session),session);
    }
 else {
      fieldValue=pkElementArray[index].getValue(key,session);
      if ((fieldValue != null) && (pkClass != null) && (mapping.isOneToOneMapping())) {
        org.eclipse.persistence.mappings.OneToOneMapping refmapping=(org.eclipse.persistence.mappings.OneToOneMapping)mapping;
        DatabaseField targetKey=refmapping.getSourceToTargetKeyFields().get(pkElementArray[index].getDatabaseField());
        CMPPolicy refPolicy=refmapping.getReferenceDescriptor().getCMPPolicy();
        if (refPolicy.isCMP3Policy()) {
          Class pkClass=refPolicy.getPKClass();
          if ((pkClass != null) && (pkClass != fieldValue.getClass()) && (!pkClass.isAssignableFrom(fieldValue.getClass()))) {
            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{pkClass,fieldValue.getClass()}));
          }
          fieldValue=((CMP3Policy)refPolicy).getPkValueFromKeyForField(fieldValue,targetKey,session);
        }
      }
    }
    pkVector.add(fieldValue);
  }
  return pkVector;
}

Fixed version (ground truth):
/** 
 * INTERNAL: Use the key to create a EclipseLink primary key Vector. If the key is simple (direct mapped) then just add it to a vector, otherwise must go through the inefficient process of copying the key into the bean and extracting the key from the bean.
 * @param key Object the primary key to use for creating the vector
 * @return Vector
 */
public Vector createPkVectorFromKey(Object key,AbstractSession session){
  KeyElementAccessor[] pkElementArray=this.getKeyClassFields(key.getClass());
  Vector pkVector=new NonSynchronizedVector(pkElementArray.length);
  for (int index=0; index < pkElementArray.length; index++) {
    DatabaseMapping mapping=pkElementArray[index].getMapping();
    Object fieldValue=null;
    if (mapping.isDirectToFieldMapping()) {
      fieldValue=((AbstractDirectMapping)mapping).getFieldValue(pkElementArray[index].getValue(key,session),session);
    }
 else {
      fieldValue=pkElementArray[index].getValue(key,session);
      if ((fieldValue != null) && (pkClass != null) && (mapping.isOneToOneMapping())) {
        OneToOneMapping refmapping=(OneToOneMapping)mapping;
        DatabaseField targetKey=refmapping.getSourceToTargetKeyFields().get(pkElementArray[index].getDatabaseField());
        CMPPolicy refPolicy=refmapping.getReferenceDescriptor().getCMPPolicy();
        if (refPolicy.isCMP3Policy()) {
          Class pkClass=refPolicy.getPKClass();
          if ((pkClass != null) && (pkClass != fieldValue.getClass()) && (!pkClass.isAssignableFrom(fieldValue.getClass()))) {
            throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",new Object[]{pkClass,fieldValue.getClass()}));
          }
          fieldValue=((CMP3Policy)refPolicy).getPkValueFromKeyForField(fieldValue,targetKey,session);
        }
      }
    }
    pkVector.add(fieldValue);
  }
  return pkVector;
}