Program: 65062
Project: 65062
Buggy source:
/** 
 * INTERNAL: Initialize the mappings as a separate step. This is done as a separate step to ensure that inheritance has been first resolved.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  if (this.hasInheritance()) {
    ((org.eclipse.persistence.internal.oxm.QNameInheritancePolicy)this.getInheritancePolicy()).setNamespaceResolver(this.getNamespaceResolver());
  }
  if (null != this.defaultRootElementField) {
    defaultRootElementField.setNamespaceResolver(this.namespaceResolver);
    defaultRootElementField.initialize();
  }
  if (schemaReference != null && schemaReference.getSchemaContext() != null && (schemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE || schemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE) && getDefaultRootElementType() == null) {
    setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
  }
  if (null != primaryKeyFields) {
    for (int x=0, primaryKeyFieldsSize=this.primaryKeyFields.size(); x < primaryKeyFieldsSize; x++) {
      XMLField pkField=(XMLField)this.primaryKeyFields.get(x);
      pkField.setNamespaceResolver(this.namespaceResolver);
      pkField.initialize();
    }
  }
  if (shouldBeReadOnly() && (!session.getDefaultReadOnlyClasses().contains(getJavaClass()))) {
    session.getDefaultReadOnlyClasses().add(getJavaClass());
  }
  if (isInitialized(INITIALIZED) || isInvalid()) {
    return;
  }
  setInitializationStage(INITIALIZED);
  if (isChildDescriptor()) {
    ClassDescriptor parentDescriptor=getInheritancePolicy().getParentDescriptor();
    parentDescriptor.initialize(session);
    if (parentDescriptor.hasEventManager()) {
      getEventManager();
    }
  }
  for (Enumeration mappingsEnum=getMappings().elements(); mappingsEnum.hasMoreElements(); ) {
    DatabaseMapping mapping=(DatabaseMapping)mappingsEnum.nextElement();
    validateMappingType(mapping);
    mapping.initialize(session);
    if (mapping.isObjectReferenceMapping()) {
      this.hasReferenceMappings=true;
    }
    if (mapping instanceof XMLChoiceObjectMapping) {
      XMLChoiceObjectMapping choiceMapping=((XMLChoiceObjectMapping)mapping);
      for (      XMLMapping next : choiceMapping.getChoiceElementMappings().values()) {
        if (((DatabaseMapping)next).isObjectReferenceMapping()) {
          this.hasReferenceMappings=true;
        }
      }
    }
    if (mapping instanceof XMLChoiceCollectionMapping) {
      XMLChoiceCollectionMapping choiceMapping=((XMLChoiceCollectionMapping)mapping);
      for (      XMLMapping next : choiceMapping.getChoiceElementMappings().values()) {
        if (((DatabaseMapping)next).isObjectReferenceMapping()) {
          this.hasReferenceMappings=true;
        }
      }
    }
    Helper.addAllUniqueToVector(getFields(),mapping.getFields());
  }
  if (hasInheritance()) {
    getInheritancePolicy().initialize(session);
  }
  setAllFields((Vector)getFields().clone());
  getObjectBuilder().initialize(session);
  if (hasInterfacePolicy()) {
    interfaceInitialization(session);
  }
  if (hasReturningPolicy()) {
    getReturningPolicy().initialize(session);
  }
  if (eventManager != null) {
    eventManager.initialize(session);
  }
  if (copyPolicy != null) {
    copyPolicy.initialize(session);
  }
  getInstantiationPolicy().initialize(session);
  if (getSchemaReference() != null) {
    getSchemaReference().initialize(session);
  }
  if (getInheritancePolicyOrNull() != null && getInheritancePolicy().getParentDescriptor() != null) {
    XMLDescriptor d=(XMLDescriptor)getInheritancePolicy().getParentDescriptor();
    locationAccessor=d.getLocationAccessor();
  }
  if (locationAccessor != null) {
    locationAccessor.initializeAttributes(getJavaClass());
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Initialize the mappings as a separate step. This is done as a separate step to ensure that inheritance has been first resolved.
 */
public void initialize(AbstractSession session) throws DescriptorException {
  if (this.hasInheritance()) {
    ((org.eclipse.persistence.internal.oxm.QNameInheritancePolicy)this.getInheritancePolicy()).setNamespaceResolver(this.getNamespaceResolver());
  }
  if (null != this.defaultRootElementField) {
    defaultRootElementField.setNamespaceResolver(this.namespaceResolver);
    defaultRootElementField.initialize();
  }
  if (schemaReference != null && schemaReference.getSchemaContext() != null && (schemaReference.getType() == XMLSchemaReference.COMPLEX_TYPE || schemaReference.getType() == XMLSchemaReference.SIMPLE_TYPE) && getDefaultRootElementType() == null) {
    if (hasInheritance() && isChildDescriptor()) {
      XMLField parentField=((XMLDescriptor)getInheritancePolicy().getParentDescriptor()).getDefaultRootElementField();
      if (parentField == null || (parentField != null && !defaultRootElementField.getXPathFragment().equals(parentField.getXPathFragment()))) {
        setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
      }
    }
 else {
      setDefaultRootElementType(schemaReference.getSchemaContextAsQName(getNamespaceResolver()));
    }
  }
  if (null != primaryKeyFields) {
    for (int x=0, primaryKeyFieldsSize=this.primaryKeyFields.size(); x < primaryKeyFieldsSize; x++) {
      XMLField pkField=(XMLField)this.primaryKeyFields.get(x);
      pkField.setNamespaceResolver(this.namespaceResolver);
      pkField.initialize();
    }
  }
  if (shouldBeReadOnly() && (!session.getDefaultReadOnlyClasses().contains(getJavaClass()))) {
    session.getDefaultReadOnlyClasses().add(getJavaClass());
  }
  if (isInitialized(INITIALIZED) || isInvalid()) {
    return;
  }
  setInitializationStage(INITIALIZED);
  if (isChildDescriptor()) {
    ClassDescriptor parentDescriptor=getInheritancePolicy().getParentDescriptor();
    parentDescriptor.initialize(session);
    if (parentDescriptor.hasEventManager()) {
      getEventManager();
    }
  }
  for (Enumeration mappingsEnum=getMappings().elements(); mappingsEnum.hasMoreElements(); ) {
    DatabaseMapping mapping=(DatabaseMapping)mappingsEnum.nextElement();
    validateMappingType(mapping);
    mapping.initialize(session);
    if (mapping.isObjectReferenceMapping()) {
      this.hasReferenceMappings=true;
    }
    if (mapping instanceof XMLChoiceObjectMapping) {
      XMLChoiceObjectMapping choiceMapping=((XMLChoiceObjectMapping)mapping);
      for (      XMLMapping next : choiceMapping.getChoiceElementMappings().values()) {
        if (((DatabaseMapping)next).isObjectReferenceMapping()) {
          this.hasReferenceMappings=true;
        }
      }
    }
    if (mapping instanceof XMLChoiceCollectionMapping) {
      XMLChoiceCollectionMapping choiceMapping=((XMLChoiceCollectionMapping)mapping);
      for (      XMLMapping next : choiceMapping.getChoiceElementMappings().values()) {
        if (((DatabaseMapping)next).isObjectReferenceMapping()) {
          this.hasReferenceMappings=true;
        }
      }
    }
    Helper.addAllUniqueToVector(getFields(),mapping.getFields());
  }
  if (hasInheritance()) {
    getInheritancePolicy().initialize(session);
  }
  setAllFields((Vector)getFields().clone());
  getObjectBuilder().initialize(session);
  if (hasInterfacePolicy()) {
    interfaceInitialization(session);
  }
  if (hasReturningPolicy()) {
    getReturningPolicy().initialize(session);
  }
  if (eventManager != null) {
    eventManager.initialize(session);
  }
  if (copyPolicy != null) {
    copyPolicy.initialize(session);
  }
  getInstantiationPolicy().initialize(session);
  if (getSchemaReference() != null) {
    getSchemaReference().initialize(session);
  }
  if (getInheritancePolicyOrNull() != null && getInheritancePolicy().getParentDescriptor() != null) {
    XMLDescriptor d=(XMLDescriptor)getInheritancePolicy().getParentDescriptor();
    locationAccessor=d.getLocationAccessor();
  }
  if (locationAccessor != null) {
    locationAccessor.initializeAttributes(getJavaClass());
  }
}