nus-yam/ex-repair huggingface dataset:
Program: 72940
Project: 72940
Buggy source:
/** 
 * Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.
 * @param container The container to attach this attribute to..
 * @exception IllegalActionException If this attribute is not of theexpected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
 * @exception NameDuplicationException If the container already hasan attribute with the name of this attribute.
 * @see #getContainer()
 */
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException {
  super.setContainer((CompositeEntity)container);
  if (container != null) {
    List<NamedObj> decoratedObjects=decoratedObjects();
    for (    NamedObj decoratedObject : decoratedObjects) {
      decoratedObject.getDecoratorAttributes(this);
    }
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.
 * @param container The container to attach this attribute to..
 * @exception IllegalActionException If this attribute is not of theexpected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
 * @exception NameDuplicationException If the container already hasan attribute with the name of this attribute.
 * @see #getContainer()
 */
@Override public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  super.setContainer((CompositeEntity)container);
  if (container != null) {
    List<NamedObj> decoratedObjects=decoratedObjects();
    for (    NamedObj decoratedObject : decoratedObjects) {
      decoratedObject.getDecoratorAttributes(this);
    }
  }
}
Program: 72941
Project: 72941
Buggy source:
/** 
 * Return a list of the entities deeply contained by the container of this resource scheduler.
 * @return A list of the objects decorated by this decorator.
 */
public List<NamedObj> decoratedObjects(){
  CompositeEntity container=(CompositeEntity)getContainer();
  return container.deepEntityList();
}

Fixed version (ground truth):
/** 
 * Return a list of the entities deeply contained by the container of this resource scheduler.
 * @return A list of the objects decorated by this decorator.
 */
public List<NamedObj> decoratedObjects(){
  CompositeEntity container=(CompositeEntity)getContainer();
  return _getEntitiesToDecorate(container);
}
Program: 72942
Project: 72942
Buggy source:
/** 
 * Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.
 * @param target The NamedObj that will be decorated.
 * @return The decorated attributes for the target NamedObj, ornull if the specified target is not an Actor.
 */
public DecoratorAttributes createDecoratorAttributes(NamedObj target){
  if (target instanceof Actor) {
    try {
      return new CompositeResourceSchedulerAttributes(target,this);
    }
 catch (    KernelException ex) {
      throw new InternalErrorException(ex);
    }
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.
 * @param target The NamedObj that will be decorated.
 * @return The decorated attributes for the target NamedObj, ornull if the specified target is not an Actor.
 */
public DecoratorAttributes createDecoratorAttributes(NamedObj target){
  if (target instanceof Actor && !_isPartOfResourceScheduler(target)) {
    try {
      return new CompositeResourceSchedulerAttributes(target,this);
    }
 catch (    KernelException ex) {
      throw new InternalErrorException(ex);
    }
  }
 else {
    return null;
  }
}
Program: 72943
Project: 72943
Buggy source:
/** 
 * If attribute is <i>messageLength</i> report the new value  to the quantity manager. 
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == requestPort) {
    Actor actor=(Actor)getContainer();
    CompositeResourceScheduler scheduler=(CompositeResourceScheduler)getDecorator();
    scheduler.setRequestPort(actor,((StringToken)((Parameter)attribute).getToken()).stringValue());
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If attribute <i>requestPort</i> report the new value  to the resource scheduler. 
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == requestPort) {
    Actor actor=(Actor)getContainer();
    CompositeResourceScheduler scheduler=(CompositeResourceScheduler)getDecorator();
    if (scheduler != null && enabled()) {
      scheduler.setRequestPort(actor,((StringToken)((Parameter)attribute).getToken()).stringValue());
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 72944
Project: 72944
Buggy source:
/** 
 * Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.
 * @param container The container to attach this attribute to..
 * @exception IllegalActionException If this attribute is not of theexpected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
 * @exception NameDuplicationException If the container already hasan attribute with the name of this attribute.
 * @see #getContainer()
 */
public void setContainer(NamedObj container) throws IllegalActionException, NameDuplicationException {
  super.setContainer((CompositeEntity)container);
  if (container != null) {
    List<NamedObj> decoratedObjects=decoratedObjects();
    for (    NamedObj decoratedObject : decoratedObjects) {
      decoratedObject.getDecoratorAttributes(this);
    }
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to first set the container, then establish a connection with any decorated objects it finds in scope in the new container.
 * @param container The container to attach this attribute to..
 * @exception IllegalActionException If this attribute is not of theexpected class for the container, or it has no name, or the attribute and container are not in the same workspace, or the proposed container would result in recursive containment.
 * @exception NameDuplicationException If the container already hasan attribute with the name of this attribute.
 * @see #getContainer()
 */
@Override public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  super.setContainer((CompositeEntity)container);
  if (container != null) {
    List<NamedObj> decoratedObjects=decoratedObjects();
    for (    NamedObj decoratedObject : decoratedObjects) {
      decoratedObject.getDecoratorAttributes(this);
    }
  }
}
Program: 72946
Project: 72946
Buggy source:
/** 
 * Construct a constant source with the default type set to the RecordToken used in the CompositeQM. 
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public ResourceMappingInputPort(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  Parameter hide=(Parameter)trigger.getAttribute("String_Node_Str");
  if (hide == null) {
    hide=new Parameter(trigger,"String_Node_Str",new BooleanToken(true));
  }
 else {
    hide.setToken(new BooleanToken(true));
  }
  value.setVisibility(Settable.NONE);
  value.setExpression("String_Node_Str");
  _beforeInitialization=true;
  RecordType type=new RecordType(new String[]{"String_Node_Str","String_Node_Str"},new Type[]{BaseType.OBJECT,BaseType.DOUBLE});
  value.setTypeEquals(type);
}

Fixed version (ground truth):
/** 
 * Construct a constant source with the default type set to the RecordToken used in the CompositeQM. 
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public ResourceMappingInputPort(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  RecordType type=new RecordType(new String[]{"String_Node_Str","String_Node_Str"},new Type[]{BaseType.OBJECT,BaseType.DOUBLE});
  value.setTypeEquals(type);
}
Program: 72947
Project: 72947
Buggy source:
/** 
 * Construct a ResourceMappingOutputPort. The contained entities (SetVariable, Parameter and input port) are created from the XML description in the library.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the container is incompatiblewith this actor.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public ResourceMappingOutputPort(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  _token=null;
}

Fixed version (ground truth):
/** 
 * Construct a ResourceMappingOutputPort. The contained entities (SetVariable, Parameter and input port) are created from the XML description in the library.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the container is incompatiblewith this actor.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public ResourceMappingOutputPort(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
}
Program: 72948
Project: 72948
Buggy source:
/** 
 * If attribute <i>requestPort</i> report the new value  to the resource scheduler. 
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == requestPort) {
    Actor actor=(Actor)getContainer();
    CompositeResourceScheduler scheduler=(CompositeResourceScheduler)getDecorator();
    if (scheduler != null && enabled()) {
      scheduler.setRequestPort(actor,((StringToken)((Parameter)attribute).getToken()).stringValue());
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If attribute <i>requestPort</i> report the new value  to the resource scheduler. 
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == requestPort) {
    Actor actor=(Actor)getContainer();
    CompositeResourceScheduler scheduler=(CompositeResourceScheduler)getDecorator();
    String portName=((StringToken)((Parameter)attribute).getToken()).stringValue();
    if (scheduler != null && portName != "String_Node_Str") {
      scheduler.setRequestPort(actor,portName);
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 72949
Project: 72949
Buggy source:
/** 
 * Each iteration has two phases. In Phase 1, MetroIIDirector calls each actor (no particular order should be presumed. See Note 1). Each actor runs until it wants to propose MetroII events: the actor saves the state and returns with MetroII events. In Phase 2, MetroIIDirector calls the MappingConstraintSolver, which updates the MetroII events based on the mapping constraints.
 */
public void fire() throws IllegalActionException {
}

Fixed version (ground truth):
/** 
 * Each iteration has two phases. In Phase 1, MetroIIDirector calls each actor (no particular order should be presumed. See Note 1). Each actor runs until it wants to propose MetroII events: the actor saves the state and returns with MetroII events. In Phase 2, MetroIIDirector calls the MappingConstraintSolver, which updates the MetroII events based on the mapping constraints.
 */
public void fire() throws IllegalActionException {
  int iterationsValue=((IntToken)iterations.getToken()).intValue();
  if (iterationsValue == 0) {
    return;
  }
  if (!_stopRequested) {
    LinkedList<Event.Builder> globalMetroIIEventList=new LinkedList<Event.Builder>();
    _debugger.printTitle(getFullName() + "String_Node_Str" + "String_Node_Str"+ Integer.toString(_iterationCount));
    _debugger.printText("String_Node_Str");
    for (    FireMachine firing : _actorList) {
      LinkedList<Event.Builder> metroIIEventList=new LinkedList<Event.Builder>();
      if (firing.getState() == FireMachine.State.START) {
        boolean result=firing.actor().prefire();
        assert result;
      }
      firing.startOrResume(metroIIEventList);
      if (firing.getState() == FireMachine.State.FINAL) {
        boolean pf=firing.actor().postfire();
        if (pf) {
          firing.reset();
          firing.startOrResume(metroIIEventList);
        }
      }
      globalMetroIIEventList.addAll(metroIIEventList);
    }
    _debugger.printText("String_Node_Str");
    _debugger.printMetroEvents(globalMetroIIEventList);
    _mappingConstraintSolver.resolve(globalMetroIIEventList);
    _timeScheduler.resolve(globalMetroIIEventList);
    _debugger.printText("String_Node_Str");
    _debugger.printMetroEvents(globalMetroIIEventList);
    _debugger.printTitle(getFullName() + "String_Node_Str" + "String_Node_Str"+ Integer.toString(_iterationCount));
    if (((BooleanToken)printTrace.getToken()).booleanValue()) {
      for (      Event.Builder event : globalMetroIIEventList) {
        if (event.getStatus() == Status.NOTIFIED) {
          System.out.println("String_Node_Str" + event.getTime().getValue() + "String_Node_Str"+ event.getName());
        }
      }
    }
  }
}
Program: 72954
Project: 72954
Buggy source:
/** 
 * Open a composite entity, if it is not already open, and recursively open any composite entities or state refinements that it contains.
 * @param entity The entity to open.
 * @param tableauxToClose A list of tableaux are newly opened.
 * @param masterEffigy The top-level effigy for the modeling being exported.
 * @param graphFrame The graph frame.
 * @exception IllegalActionException If opening fails.
 * @exception NameDuplicationException Not thrown.
 */
private static void _openComposite(CompositeEntity entity,Set<Tableau> tableauxToClose,Effigy masterEffigy,BasicGraphFrame graphFrame) throws IllegalActionException {
  Configuration configuration=graphFrame.getConfiguration();
  Effigy effigy=configuration.getEffigy(entity);
  if (effigy != null) {
    List<Tableau> tableaux=effigy.entityList(Tableau.class);
    if (tableaux == null || tableaux.size() == 0) {
      tableauxToClose.add(configuration.createPrimaryTableau(effigy));
    }
  }
 else {
    Tableau tableau;
    try {
      tableau=configuration.openModel(entity);
      tableauxToClose.add(tableau);
    }
 catch (    NameDuplicationException e) {
      throw new InternalErrorException(e);
    }
  }
  List<Entity> entities=entity.entityList();
  for (  Entity inside : entities) {
    _openEntity(inside,tableauxToClose,masterEffigy,graphFrame);
  }
}

Fixed version (ground truth):
/** 
 * Open a composite entity, if it is not already open, and recursively open any composite entities or state refinements that it contains.
 * @param entity The entity to open.
 * @param tableauxToClose A list of tableaux are newly opened.
 * @param masterEffigy The top-level effigy for the modeling being exported.
 * @param graphFrame The graph frame.
 * @exception IllegalActionException If opening fails.
 * @exception NameDuplicationException Not thrown.
 */
private static void _openComposite(CompositeEntity entity,Set<Tableau> tableauxToClose,Effigy masterEffigy,BasicGraphFrame graphFrame) throws IllegalActionException {
  Configuration configuration=graphFrame.getConfiguration();
  Effigy effigy=configuration.getEffigy(entity);
  Tableau tableau;
  if (effigy != null) {
    List<Tableau> tableaux=effigy.entityList(Tableau.class);
    if (tableaux == null || tableaux.size() == 0) {
      tableau=configuration.createPrimaryTableau(effigy);
      tableauxToClose.add(tableau);
    }
 else {
      tableau=tableaux.get(0);
    }
  }
 else {
    try {
      tableau=configuration.openModel(entity);
      tableauxToClose.add(tableau);
    }
 catch (    NameDuplicationException e) {
      throw new InternalErrorException(e);
    }
  }
  CompositeEntity actualEntity=entity;
  if (tableau instanceof ActorGraphTableau) {
    PtolemyEffigy actualEffigy=(PtolemyEffigy)tableau.getContainer();
    actualEntity=(CompositeEntity)actualEffigy.getModel();
  }
  List<Entity> entities=actualEntity.entityList();
  for (  Entity inside : entities) {
    _openEntity(inside,tableauxToClose,masterEffigy,graphFrame);
  }
}
Program: 72955
Project: 72955
Buggy source:
/** 
 * Return the list of quantity managers in this port. A quantity manager is a   {@link Parameter} whose value is an{@link ObjectToken} that references an object that implementsthe  {@link QuantityManager} interface.
 * @return The list of quantity managers.
 * @exception IllegalActionException Thrown if the token of the parametercontaining the quantity manager object cannot be retrieved.
 */
public List<QuantityManager> getQuantityManagers() throws IllegalActionException {
  _qmList=new ArrayList<QuantityManager>();
  List<ResourceAttributes> list=this.attributeList(ResourceAttributes.class);
  for (  ResourceAttributes attribute : list) {
    if (attribute.enabled()) {
      _qmList.add((QuantityManager)attribute.getDecorator());
    }
  }
  _qmListValid=true;
  return _qmList;
}

Fixed version (ground truth):
/** 
 * Return the list of quantity managers in this port. A quantity manager is a   {@link Parameter} whose value is an{@link ObjectToken} that references an object that implementsthe  {@link QuantityManager} interface.
 * @return The list of quantity managers.
 * @exception IllegalActionException Thrown if the token of the parametercontaining the quantity manager object cannot be retrieved.
 */
public List<QuantityManager> getQuantityManagers() throws IllegalActionException {
  _qmList=new ArrayList<QuantityManager>();
  List<ResourceAttributes> list=this.attributeList(ResourceAttributes.class);
  for (  ResourceAttributes attribute : list) {
    if (attribute.enabled()) {
      if ((QuantityManager)attribute.getDecorator() != null) {
        _qmList.add((QuantityManager)attribute.getDecorator());
        attribute.validateSettables();
      }
    }
  }
  _qmListValid=true;
  return _qmList;
}
Program: 72956
Project: 72956
Buggy source:
@Override public boolean postfire() throws IllegalActionException {
  boolean postfire=super.postfire();
  for (  Object entity : entityList()) {
    if (entity instanceof ResourceMappingOutputPort) {
      ResourceMappingOutputPort outputPort=((ResourceMappingOutputPort)entity);
      if (outputPort.hasToken() && outputPort.getToken() instanceof RecordToken) {
        RecordToken recordToken=(RecordToken)outputPort.getToken();
        if (recordToken.get("String_Node_Str") != null && ((ObjectToken)recordToken.get("String_Node_Str")).getValue() != null) {
          Actor actor=(Actor)((ObjectToken)recordToken.get("String_Node_Str")).getValue();
          event((NamedObj)actor,getDirector().getModelTime().getDoubleValue(),ExecutionEventType.STOP);
          outputPort.takeToken();
          _currentlyExecuting.remove(actor);
          actor.getDirector().resumeActor(actor);
          _lastActorFinished=true;
        }
      }
    }
  }
  return postfire;
}

Fixed version (ground truth):
@Override public boolean postfire() throws IllegalActionException {
  boolean postfire=super.postfire();
  for (  Object entity : entityList()) {
    if (entity instanceof ResourceMappingOutputPort) {
      ResourceMappingOutputPort outputPort=((ResourceMappingOutputPort)entity);
      if (outputPort.hasToken() && outputPort.getToken() instanceof RecordToken) {
        RecordToken recordToken=(RecordToken)outputPort.getToken();
        if (recordToken.get("String_Node_Str") != null && ((ObjectToken)recordToken.get("String_Node_Str")).getValue() != null) {
          Actor actor=(Actor)((ObjectToken)recordToken.get("String_Node_Str")).getValue();
          event((NamedObj)actor,getExecutiveDirector().getModelTime().getDoubleValue(),ExecutionEventType.STOP);
          outputPort.takeToken();
          _currentlyExecuting.remove(actor);
          actor.getExecutiveDirector().resumeActor(actor);
          _lastActorFinished=true;
        }
      }
    }
  }
  return postfire;
}
Program: 72958
Project: 72958
Buggy source:
public void getfire(ResultHandler<Iterable<Event.Builder>> resultHandler) throws CollectionAbortedException {
  while (!createProcess) {
  }
  syncEvents(events);
  do {
    resultHandler.handleResult(events);
  }
 while (!atLeastOneNotified(events));
  pushEvents(events);
}

Fixed version (ground truth):
public void getfire(ResultHandler<Iterable<Event.Builder>> resultHandler) throws CollectionAbortedException {
  syncEvents(events);
  do {
    resultHandler.handleResult(events);
  }
 while (!atLeastOneNotified(events));
  pushEvents(events);
}
Program: 72959
Project: 72959
Buggy source:
/** 
 * Add names of available CQMInputPort in CompositeQM as choices to inputPort.
 * @exception InteralErrorException Thrown if CompositeQMcannot be accessed.  
 */
@Override public void updateContent() throws InternalErrorException {
  super.updateContent();
  try {
    if (getDecorator() != null) {
      List<String> choices=new ArrayList();
      if (inputPort.getChoices() != null) {
        for (int i=0; i < inputPort.getChoices().length; i++) {
          choices.add(inputPort.getChoices()[i]);
        }
      }
      List cqmInputPorts=((CompositeQM)getDecorator()).entityList(CQMInputPort.class);
      for (      Object cqmInputPort : cqmInputPorts) {
        String name=((CQMInputPort)cqmInputPort).getName();
        if (!choices.contains(name)) {
          inputPort.addChoice(name);
        }
      }
    }
  }
 catch (  IllegalActionException e) {
    throw new InternalErrorException(e);
  }
}

Fixed version (ground truth):
/** 
 * Add names of available CQMInputPort in CompositeQM as choices to inputPort.
 * @exception InteralErrorException Thrown if CompositeQMcannot be accessed.  
 */
@Override public void updateContent() throws InternalErrorException {
  super.updateContent();
  try {
    if (getDecorator() != null) {
      inputPort.removeAllChoices();
      List cqmInputPorts=((CompositeQM)getDecorator()).entityList(CQMInputPort.class);
      for (      Object cqmInputPort : cqmInputPorts) {
        String name=((CQMInputPort)cqmInputPort).getName();
        inputPort.addChoice(name);
      }
    }
  }
 catch (  IllegalActionException e) {
    throw new InternalErrorException(e);
  }
}
Program: 72960
Project: 72960
Buggy source:
/** 
 * Add names of available CQMInputPort in CompositeQM as choices to inputPort.
 * @exception InteralErrorException Thrown if CompositeQMcannot be accessed.  
 */
@Override public void updateContent() throws InternalErrorException {
  super.updateContent();
  try {
    if (getDecorator() != null) {
      List<String> choices=new ArrayList();
      if (requestPort.getChoices() != null) {
        for (int i=0; i < requestPort.getChoices().length; i++) {
          choices.add(requestPort.getChoices()[i]);
        }
      }
      List cqmInputPorts=((CompositeResourceScheduler)getDecorator()).entityList(ResourceMappingInputPort.class);
      for (      Object cqmInputPort : cqmInputPorts) {
        String name=((ResourceMappingInputPort)cqmInputPort).getName();
        if (!choices.contains(name)) {
          requestPort.addChoice(name);
        }
      }
    }
  }
 catch (  IllegalActionException e) {
    throw new InternalErrorException(e);
  }
}

Fixed version (ground truth):
/** 
 * Add names of available CQMInputPort in CompositeQM as choices to inputPort.
 * @exception InteralErrorException Thrown if CompositeQMcannot be accessed.  
 */
@Override public void updateContent() throws InternalErrorException {
  super.updateContent();
  try {
    if (getDecorator() != null) {
      requestPort.removeAllChoices();
      List cqmInputPorts=((CompositeResourceScheduler)getDecorator()).entityList(ResourceMappingInputPort.class);
      for (      Object cqmInputPort : cqmInputPorts) {
        String name=((ResourceMappingInputPort)cqmInputPort).getName();
        requestPort.addChoice(name);
      }
    }
  }
 catch (  IllegalActionException e) {
    throw new InternalErrorException(e);
  }
}
Program: 72962
Project: 72962
Buggy source:
public void resumeActor(Actor actor) throws IllegalActionException {
  _actorsFinished.add(actor);
  System.out.println("String_Node_Str" + actor);
}

Fixed version (ground truth):
public void resumeActor(Actor actor) throws IllegalActionException {
  _actorsFinished.add(actor);
}
Program: 72965
Project: 72965
Buggy source:
/** 
 * The postfire() counts the number of iterations and returns false when the number of iteration exceeds the parameter iterations. postfire() will always return true if the parameter iterations is less or equal to 0.
 */
public boolean postfire() throws IllegalActionException {
  _iterationCount++;
  int iterationsValue=((IntToken)iterations.getToken()).intValue();
  if (_stopRequested || iterationsValue > 0 && _iterationCount >= iterationsValue) {
    _iterationCount=0;
    for (    StartOrResumable actor : _actorList) {
      actor.reset();
    }
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * The postfire() counts the number of iterations and returns false when the number of iteration exceeds the parameter iterations. postfire() will always return true if the parameter iterations is less or equal to 0.
 */
public boolean postfire() throws IllegalActionException {
  _iterationCount++;
  int iterationsValue=((IntToken)iterations.getToken()).intValue();
  if (_stopRequested || iterationsValue >= 0 && _iterationCount >= iterationsValue) {
    _iterationCount=0;
    for (    StartOrResumable actor : _actorList) {
      actor.reset();
    }
    return false;
  }
  return true;
}
Program: 72967
Project: 72967
Buggy source:
/** 
 * If attribute is <i>messageLength</i> report the new value  to the quantity manager. 
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == messageLength) {
    IOPort port=(IOPort)getContainer();
    Bus bus=(Bus)getDecorator();
    bus.setMessageLength(port,((ScalarToken)((Parameter)attribute).getToken()).doubleValue());
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If attribute is <i>messageLength</i> report the new value  to the quantity manager. 
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == messageLength) {
    IOPort port=(IOPort)getContainer();
    Bus bus=(Bus)getDecorator();
    if (bus != null) {
      Token token=messageLength.getToken();
      if (token != null) {
        bus.setMessageLength(port,((ScalarToken)token).doubleValue());
      }
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 72968
Project: 72968
Buggy source:
/** 
 * Do not set a value before initialization.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException Not thrown here.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == value && _beforeInitialization) {
    value.setExpression("String_Node_Str");
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * Do not set a value before initialization.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException Not thrown here.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == value && _beforeInitialization) {
  }
  super.attributeChanged(attribute);
}
Program: 72969
Project: 72969
Buggy source:
/** 
 * Initialize the iteration counter.  A derived class must call this method in its initialize() method or the <i>firingCountLimit</i> feature will not work.
 * @exception IllegalActionException If the parent class throws it,which could occur if, for example, the director will not accept sequence actors.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  value.setExpression("String_Node_Str");
  _beforeInitialization=false;
}

Fixed version (ground truth):
/** 
 * Initialize the iteration counter.  A derived class must call this method in its initialize() method or the <i>firingCountLimit</i> feature will not work.
 * @exception IllegalActionException If the parent class throws it,which could occur if, for example, the director will not accept sequence actors.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _beforeInitialization=false;
}
Program: 72970
Project: 72970
Buggy source:
/** 
 * Construct a constant source with the default type set to the RecordToken used in the CompositeQM. 
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public CQMInputPort(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  Parameter hide=(Parameter)trigger.getAttribute("String_Node_Str");
  if (hide == null) {
    hide=new Parameter(trigger,"String_Node_Str",new BooleanToken(true));
  }
 else {
    hide.setToken(new BooleanToken(true));
  }
  _beforeInitialization=true;
  value.setExpression("String_Node_Str");
  value.setVisibility(Settable.NONE);
  firingCountLimit.setVisibility(Settable.NONE);
  output.setTypeEquals(new RecordType(new String[]{"String_Node_Str","String_Node_Str"},new Type[]{BaseType.OBJECT,BaseType.GENERAL}));
}

Fixed version (ground truth):
/** 
 * Construct a constant source with the default type set to the RecordToken used in the CompositeQM. 
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public CQMInputPort(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  Parameter hide=(Parameter)trigger.getAttribute("String_Node_Str");
  if (hide == null) {
    hide=new Parameter(trigger,"String_Node_Str",new BooleanToken(true));
  }
 else {
    hide.setToken(new BooleanToken(true));
  }
  _beforeInitialization=true;
  value.setVisibility(Settable.NONE);
  value.setExpression("String_Node_Str");
  firingCountLimit.setVisibility(Settable.NONE);
  value.setTypeEquals(new RecordType(new String[]{"String_Node_Str","String_Node_Str"},new Type[]{BaseType.OBJECT,BaseType.DOUBLE}));
}
Program: 72971
Project: 72971
Buggy source:
/** 
 * Check whether the contained parameter contains a token.
 * @return True if the contained parameter contains a token.
 * @exception IllegalActionException Thrown if token cannotbe accessed. 
 */
public boolean hasToken() throws IllegalActionException {
  return ((Parameter)getAttribute("String_Node_Str")).getToken() != null;
}

Fixed version (ground truth):
/** 
 * Check whether the contained parameter contains a token.
 * @return True if the contained parameter contains a token.
 * @exception IllegalActionException Thrown if token cannotbe accessed. 
 */
public boolean hasToken() throws IllegalActionException {
  Token token=((Parameter)getAttribute("String_Node_Str")).getToken();
  if (token != null && !(token instanceof BooleanToken)) {
    return true;
  }
  return false;
}
Program: 72972
Project: 72972
Buggy source:
/** 
 * Get token from parameter and remove it from the parameter.
 * @return The token.
 * @exception IllegalActionException Thrown if token cannotbe accessed. 
 */
public Token takeToken() throws IllegalActionException {
  Token token=((Parameter)getAttribute("String_Node_Str")).getToken();
  ((Parameter)getAttribute("String_Node_Str")).reset();
  return token;
}

Fixed version (ground truth):
/** 
 * Get token from parameter and remove it from the parameter.
 * @return The token.
 * @exception IllegalActionException Thrown if token cannotbe accessed. 
 */
public Token takeToken() throws IllegalActionException {
  Token token=((Parameter)getAttribute("String_Node_Str")).getToken();
  ((Parameter)getAttribute("String_Node_Str")).setToken(new BooleanToken(false));
  return token;
}
Program: 72973
Project: 72973
Buggy source:
/** 
 * Override the fire and change the transferring tokens from and to input/output placeholders.
 */
public void fire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str" + getDirector().getModelTime());
  }
  try {
    _workspace.getReadAccess();
    if (!isOpaque()) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    if (_stopRequested) {
      return;
    }
    for (    Const mappedConst : _tokens.keySet()) {
      mappedConst.value.setToken(_tokens.get(mappedConst));
      mappedConst.fire();
      System.out.println(mappedConst);
    }
    _tokens.clear();
    getDirector().fire();
    if (_stopRequested) {
      return;
    }
    for (    Object entity : entityList()) {
      if (entity instanceof CQMOutputPort) {
        CQMOutputPort outputPort=((CQMOutputPort)entity);
        while (outputPort.hasToken()) {
          RecordToken recordToken=(RecordToken)outputPort.takeToken();
          Receiver receiver=(Receiver)((ObjectToken)recordToken.get("String_Node_Str")).getValue();
          Token token=recordToken.get("String_Node_Str");
          receiver.put(token);
        }
      }
    }
  }
  finally {
    _workspace.doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Override the fire and change the transferring tokens from and to input/output placeholders.
 */
public void fire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str" + getDirector().getModelTime());
  }
  try {
    _workspace.getReadAccess();
    if (!isOpaque()) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    if (_stopRequested) {
      return;
    }
    for (    Const mappedConst : _tokens.keySet()) {
      mappedConst.value.setToken(_tokens.get(mappedConst));
      mappedConst.fire();
    }
    _tokens.clear();
    getDirector().fire();
    if (_stopRequested) {
      return;
    }
    for (    Object entity : entityList()) {
      if (entity instanceof CQMOutputPort) {
        CQMOutputPort outputPort=((CQMOutputPort)entity);
        while (outputPort.hasToken()) {
          RecordToken recordToken=(RecordToken)outputPort.takeToken();
          Receiver receiver=(Receiver)((ObjectToken)recordToken.get("String_Node_Str")).getValue();
          Token token=recordToken.get("String_Node_Str");
          receiver.put(token);
        }
      }
    }
  }
  finally {
    _workspace.doneReading();
  }
}
Program: 72975
Project: 72975
Buggy source:
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  Nameable container=getContainer();
  if (container instanceof CompositeActor) {
    Iterator<?> actors=((CompositeActor)container).deepEntityList().iterator();
    _actorDictionary.clear();
    _pendingIteration.clear();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      if (actor instanceof MetroIIEventHandler) {
        _actorDictionary.put(actor.getFullName(),new ResumableFire(actor));
      }
 else {
        _actorDictionary.put(actor.getFullName(),new NonBlockingFire(actor));
      }
      _pendingIteration.put(actor.getFullName(),0);
    }
  }
  _events=new ArrayList<Event.Builder>();
  actorList=new ArrayList<Actor>();
}

Fixed version (ground truth):
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  Nameable container=getContainer();
  if (container instanceof CompositeActor) {
    Iterator<?> actors=((CompositeActor)container).deepEntityList().iterator();
    _actorDictionary.clear();
    _pendingIteration.clear();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      if (actor instanceof MetroIIEventHandler) {
        _actorDictionary.put(actor.getFullName(),new ResumableFire(actor));
      }
      _pendingIteration.put(actor.getFullName(),0);
    }
  }
  _events=new ArrayList<Event.Builder>();
  actorList=new ArrayList<Actor>();
}
Program: 72980
Project: 72980
Buggy source:
/** 
 * Generate a new random number.
 * @exception IllegalActionException If parameter values are incorrect.
 */
protected void _generateRandomNumber() throws IllegalActionException {
  double meanTimeValue=((DoubleToken)meanTime.getToken()).doubleValue();
  _current=-Math.log(1 - _random.nextDouble()) * meanTimeValue;
}

Fixed version (ground truth):
/** 
 * Generate a new random number.
 * @exception IllegalActionException If parameter values are incorrect.
 */
protected void _generateRandomNumber() throws IllegalActionException {
  double meanTimeValue=((DoubleToken)meanTime.getToken()).doubleValue();
  double test=_random.nextDouble();
  _current=-Math.log(1 - test) * meanTimeValue;
}
Program: 72981
Project: 72981
Buggy source:
/** 
 * Clone the actor into the specified workspace.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  HlaManager newObject=(HlaManager)super.clone(workspace);
  newObject._hlaAttributesToPublish=new HashMap<String,Object[]>();
  newObject._hlaAttributesSubscribedTo=new HashMap<String,Object[]>();
  newObject._fromFederationEvents=new HashMap<String,LinkedList<TimedEvent>>();
  newObject._attributes=null;
  newObject._rtia=null;
  newObject._fedAmb=null;
  newObject._federateName=_federateName;
  newObject._federationName=_federationName;
  newObject._isTimeConstrained=_isTimeConstrained;
  newObject._isTimeRegulator=_isTimeRegulator;
  newObject._hlaStartTime=_hlaStartTime;
  newObject._hlaTimeStep=_hlaTimeStep;
  newObject._hlaLookAHead=_hlaLookAHead;
  newObject._requireSynchronization=_requireSynchronization;
  newObject._synchronizationPointName=_synchronizationPointName;
  newObject._isCreatorSyncPt=_isCreatorSyncPt;
  newObject._useNextEventRequest=_useNextEventRequest;
  newObject._useTimeAdvancedRequest=_useTimeAdvancedRequest;
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  HlaManager newObject=(HlaManager)super.clone(workspace);
  newObject._hlaAttributesToPublish=new HashMap<String,Object[]>();
  newObject._hlaAttributesSubscribedTo=new HashMap<String,Object[]>();
  newObject._fromFederationEvents=new HashMap<String,LinkedList<TimedEvent>>();
  newObject._attributes=null;
  newObject._rtia=null;
  newObject._fedAmb=null;
  newObject._federateName=_federateName;
  newObject._federationName=_federationName;
  newObject._isTimeConstrained=_isTimeConstrained;
  newObject._isTimeRegulator=_isTimeRegulator;
  try {
    newObject._hlaStartTime=((DoubleToken)hlaStartTime.getToken()).doubleValue();
    newObject._hlaTimeStep=((DoubleToken)hlaTimeStep.getToken()).doubleValue();
    newObject._hlaLookAHead=((DoubleToken)hlaLookAHead.getToken()).doubleValue();
  }
 catch (  IllegalActionException ex) {
    CloneNotSupportedException ex2=new CloneNotSupportedException("String_Node_Str");
    ex2.initCause(ex);
    throw ex2;
  }
  newObject._requireSynchronization=_requireSynchronization;
  newObject._synchronizationPointName=_synchronizationPointName;
  newObject._isCreatorSyncPt=_isCreatorSyncPt;
  newObject._useNextEventRequest=_useNextEventRequest;
  newObject._useTimeAdvancedRequest=_useTimeAdvancedRequest;
  return newObject;
}
Program: 72984
Project: 72984
Buggy source:
/** 
 * Generate include files. FIXME: State what is included.
 * @return The #include statements, surrounded by #ifndef to ensurethat the files are included only once.
 * @exception IllegalActionException If the adapter class for some actorcannot be found.
 */
protected String _generateIncludeFiles() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  NamedProgramCodeGeneratorAdapter compositeActorAdapter=(NamedProgramCodeGeneratorAdapter)getAdapter(getContainer());
  Set<String> includingFiles=compositeActorAdapter.getHeaderFiles();
  includingFiles.add("String_Node_Str");
  if (_isTopLevel() && ((BooleanToken)measureTime.getToken()).booleanValue()) {
    includingFiles.add("String_Node_Str");
  }
  if (!_isTopLevel()) {
    includingFiles.add("String_Node_Str" + _sanitizedModelName + "String_Node_Str");
    includingFiles.addAll(_getJVMHeaderFiles());
  }
  if (((BooleanToken)generateEmbeddedCode.getToken()).booleanValue()) {
    includingFiles.addAll(_getJVMHeaderFiles());
  }
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  for (  String file : includingFiles) {
    if (file.endsWith("String_Node_Str"))     code.append("String_Node_Str" + file.substring(1) + _eol);
 else     code.append("String_Node_Str" + file + _eol);
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate include files. FIXME: State what is included.
 * @return The #include statements, surrounded by #ifndef to ensurethat the files are included only once.
 * @exception IllegalActionException If the adapter class for some actorcannot be found.
 */
protected String _generateIncludeFiles() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  NamedProgramCodeGeneratorAdapter compositeActorAdapter=(NamedProgramCodeGeneratorAdapter)getAdapter(getContainer());
  Set<String> includingFiles=compositeActorAdapter.getHeaderFiles();
  includingFiles.add("String_Node_Str");
  if (_isTopLevel() && ((BooleanToken)measureTime.getToken()).booleanValue()) {
    includingFiles.add("String_Node_Str");
  }
  if (!_isTopLevel()) {
    includingFiles.add("String_Node_Str" + _sanitizedModelName + "String_Node_Str");
    includingFiles.addAll(_getJVMHeaderFiles());
  }
  if (((BooleanToken)generateEmbeddedCode.getToken()).booleanValue()) {
    includingFiles.addAll(_getJVMHeaderFiles());
  }
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  includingFiles.add("String_Node_Str");
  for (  String file : includingFiles) {
    if (file.endsWith("String_Node_Str") && _isTopLevel())     code.append("String_Node_Str" + file.substring(1) + _eol);
 else     code.append("String_Node_Str" + file + _eol);
  }
  return code.toString();
}
Program: 72987
Project: 72987
Buggy source:
/** 
 * Add a new event to the input queue. Compute the time when this input can be consumed and store in queue. The time depends on the device delay.
 * @param sourcePort the source port.
 * @param event New input event.
 * @param deviceDelay The device delay.
 * @exception IllegalActionException If device delay parameter cannot be computed.
 */
public void addInputEvent(PtidesPort sourcePort,PtidesEvent event,double deviceDelay) throws IllegalActionException {
  if (sourcePort.isNetworkReceiverPort()) {
    double networkDelayBound=PtidesDirector._getDoubleParameterValue(sourcePort,"String_Node_Str");
    double sourcePlatformDelayBound=PtidesDirector._getDoubleParameterValue(sourcePort,"String_Node_Str");
    double clockSynchronizationErrorBound=PtidesDirector._getDoubleParameterValue(sourcePort,"String_Node_Str");
    if (localClock.getLocalTime().subtract(event.timeStamp()).getDoubleValue() > sourcePlatformDelayBound + networkDelayBound + clockSynchronizationErrorBound) {
      event=_handleTimingError(sourcePort,event,"String_Node_Str" + "String_Node_Str" + localClock.getLocalTime() + "String_Node_Str"+ event.timeStamp()+ "String_Node_Str"+ sourcePlatformDelayBound+ "String_Node_Str"+ networkDelayBound+ "String_Node_Str");
    }
  }
  if (event != null) {
    Time inputReady=getModelTime().add(deviceDelay);
    List<PtidesEvent> list=_inputEventQueue.get(inputReady);
    if (list == null) {
      list=new ArrayList<PtidesEvent>();
    }
    list.add(event);
    _inputEventQueue.put(inputReady,list);
  }
}

Fixed version (ground truth):
/** 
 * Add a new event to the input queue. Compute the time when this input can be consumed and store in queue. The time depends on the device delay.
 * @param sourcePort the source port.
 * @param event New input event.
 * @param deviceDelay The device delay.
 * @exception IllegalActionException If device delay parameter cannot be computed.
 */
public void addInputEvent(PtidesPort sourcePort,PtidesEvent event,double deviceDelay) throws IllegalActionException {
  if (sourcePort.isNetworkReceiverPort()) {
    double networkDelayBound=PtidesDirector._getDoubleParameterValue(sourcePort,"String_Node_Str");
    double sourcePlatformDelayBound=PtidesDirector._getDoubleParameterValue(sourcePort,"String_Node_Str");
    if (localClock.getLocalTime().subtract(event.timeStamp()).getDoubleValue() > sourcePlatformDelayBound + networkDelayBound + _clockSynchronizationErrorBound) {
      event=_handleTimingError(sourcePort,event,"String_Node_Str" + "String_Node_Str" + localClock.getLocalTime() + "String_Node_Str"+ event.timeStamp()+ "String_Node_Str"+ sourcePlatformDelayBound+ "String_Node_Str"+ networkDelayBound+ "String_Node_Str");
    }
  }
  if (event != null) {
    Time inputReady=getModelTime().add(deviceDelay);
    List<PtidesEvent> list=_inputEventQueue.get(inputReady);
    if (list == null) {
      list=new ArrayList<PtidesEvent>();
    }
    list.add(event);
    _inputEventQueue.put(inputReady,list);
  }
}
Program: 72988
Project: 72988
Buggy source:
public void printMetroEvent(Builder event){
  if (!_debugging) {
    return;
  }
  String buffer="String_Node_Str";
  if (event.hasTime()) {
    buffer=buffer.concat("String_Node_Str" + Long.toString(event.getTime()));
  }
  buffer=buffer.concat("String_Node_Str" + event.getStatus().toString());
  buffer=buffer.concat("String_Node_Str" + event.getName().toString());
  System.out.println(buffer);
}

Fixed version (ground truth):
public void printMetroEvent(Builder event){
  if (!_debugging) {
    return;
  }
  String buffer="String_Node_Str";
  if (event.hasTime()) {
    buffer=buffer.concat("String_Node_Str" + event.getTime());
  }
  buffer=buffer.concat("String_Node_Str" + event.getStatus().toString());
  buffer=buffer.concat("String_Node_Str" + event.getName().toString());
  System.out.println(buffer);
}