Program: 2517
Project: 2517
Buggy source:
/** 
 * This method projects the supplied model object based on the specified role.
 * @param model The model object
 * @param role The role
 * @param l The model listener
 * @return The projected model object
 */
public ModelObject project(ProjectorContext context,ModelObject model,Role role,Journal l){
  Run ret=new Run();
  Run source=(Run)model;
  ret.derivedFrom(source);
  java.util.List<Parameter> params=source.getParameters();
  int mappedIndex=-1;
  for (int i=0; i < params.size(); i++) {
    Parameter db=params.get(i);
    if (db.getName().equals(role.getName()) == false) {
      Parameter dbcopy=new Parameter(db.getName());
      dbcopy.derivedFrom(db);
      ret.getParameters().add(dbcopy);
    }
 else {
      mappedIndex=i;
    }
  }
  if (source.getProtocolReference() != null) {
    boolean f_inner=false;
    Protocol defn=RunUtil.getInnerProtocol(source.enclosingProtocol(),source.getProtocolReference());
    if (defn == null) {
      ProtocolImport pi=ProtocolModelUtil.getProtocolImport(source.getModel(),source.getProtocolReference());
      if (pi == null) {
        l.error("String_Node_Str" + source.getProtocolReference().getName() + "String_Node_Str",source.getProperties());
      }
 else {
        ProtocolModel pm=context.getProtocolContext().getProtocolModel(pi,l);
        if (pm != null) {
          defn=pm.getProtocol();
        }
 else {
          l.error("String_Node_Str" + source.getProtocolReference().getName() + "String_Node_Str"+ pi.getLocation()+ "String_Node_Str",source.getProperties());
        }
      }
    }
 else {
      f_inner=true;
    }
    if (defn != null && mappedIndex != -1) {
      Role mappedRole=null;
      if (mappedIndex < defn.getParameterDefinitions().size()) {
        ParameterDefinition pd=defn.getParameterDefinitions().get(mappedIndex);
        if (pd.getType() != null) {
          l.error("String_Node_Str",source.getProperties());
        }
 else {
          mappedRole=new Role(pd.getName());
        }
      }
 else {
        l.error("String_Node_Str",source.getProperties());
      }
      if (mappedRole != null) {
        if (f_inner) {
          context.registerInterest(defn,mappedRole);
        }
        ret.setProtocolReference((ProtocolReference)context.project(source.getProtocolReference(),mappedRole,l));
      }
    }
 else {
      ret=null;
    }
  }
  if (ret != null && source.getBlock() != null) {
    ret.setBlock((Block)context.project(source.getBlock(),role,l));
    ret.getBlock().setParent(ret);
  }
  return (ret);
}

Fixed version (ground truth):
/** 
 * This method projects the supplied model object based on the specified role.
 * @param model The model object
 * @param role The role
 * @param l The model listener
 * @return The projected model object
 */
public ModelObject project(ProjectorContext context,ModelObject model,Role role,Journal l){
  Run ret=new Run();
  Run source=(Run)model;
  ret.derivedFrom(source);
  java.util.List<Parameter> params=source.getParameters();
  int mappedIndex=-1;
  for (int i=0; i < params.size(); i++) {
    Parameter db=params.get(i);
    if (db.getName().equals(role.getName()) == false) {
      Parameter dbcopy=new Parameter(db.getName());
      dbcopy.derivedFrom(db);
      ret.getParameters().add(dbcopy);
    }
 else {
      mappedIndex=i;
    }
  }
  if (source.getProtocolReference() != null) {
    boolean f_inner=false;
    Protocol defn=RunUtil.getInnerProtocol(source.enclosingProtocol(),source.getProtocolReference());
    if (defn == null) {
      ProtocolImport pi=ProtocolModelUtil.getProtocolImport(source.getModel(),source.getProtocolReference());
      if (pi == null) {
        l.error("String_Node_Str" + source.getProtocolReference().getName() + "String_Node_Str",source.getProperties());
      }
 else {
        ProtocolModel pm=context.getProtocolContext().getProtocolModel(pi,l);
        if (pm != null) {
          defn=pm.getProtocol();
        }
 else {
          l.error("String_Node_Str" + source.getProtocolReference().getName() + "String_Node_Str"+ pi.getLocation()+ "String_Node_Str",source.getProperties());
        }
      }
    }
 else {
      f_inner=true;
    }
    if (defn != null && mappedIndex != -1) {
      Role mappedRole=null;
      if (mappedIndex < defn.getParameterDefinitions().size()) {
        ParameterDefinition pd=defn.getParameterDefinitions().get(mappedIndex);
        if (pd.getType() != null) {
          l.error("String_Node_Str",source.getProperties());
        }
 else {
          mappedRole=new Role(pd.getName());
        }
      }
 else {
        l.error("String_Node_Str",source.getProperties());
      }
      if (mappedRole != null) {
        if (f_inner) {
          context.registerInterest(defn,mappedRole);
        }
        ret.setProtocolReference((ProtocolReference)context.project(source.getProtocolReference(),mappedRole,l));
      }
    }
 else {
      ret=null;
    }
  }
  if (ret != null && source.getBlock() != null) {
    ret.setBlock((Block)context.project(source.getBlock(),role,l));
    ret.getBlock().setParent(ret);
    if (ret.getBlock().size() == 0 && ret.getProtocolReference() == null) {
      ret=null;
    }
  }
  return (ret);
}