nus-yam/ex-repair huggingface dataset:
Program: 73036
Project: 73036
Buggy source:
/** 
 * Send token to receiver.
 * @param receiver The receiver.
 * @param token The token.
 * @exception NoRoomException If the receiver has no room for the token.
 * @exception IllegalActionException If the receiver cannot receive the token.
 */
protected void _sendToReceiver(Receiver receiver,Token token) throws NoRoomException, IllegalActionException {
  if (receiver instanceof IntermediateReceiver) {
    ((IntermediateReceiver)receiver).source=this;
  }
  receiver.put(token);
  _tokenCount--;
  sendQMTokenEvent((Actor)receiver.getContainer().getContainer(),0,_tokenCount,EventType.SENT);
}

Fixed version (ground truth):
/** 
 * Send token to receiver.
 * @param receiver The receiver.
 * @param token The token.
 * @exception NoRoomException If the receiver has no room for the token.
 * @exception IllegalActionException If the receiver cannot receive the token.
 */
protected void _sendToReceiver(Receiver receiver,Token token) throws NoRoomException, IllegalActionException {
  if (receiver instanceof IntermediateReceiver) {
    ((IntermediateReceiver)receiver).source=this;
  }
  receiver.put(token);
}
Program: 73038
Project: 73038
Buggy source:
/** 
 * If there are still tokens in the queue and a token has been produced in the fire, schedule a refiring.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    _tokens.take();
    _tokenCount--;
    sendQMTokenEvent(null,0,_tokenCount,EventType.RECEIVED);
  }
  if ((getDirector() instanceof FixedPointDirector) && _receiversAndTokensToSendTo != null) {
    while (_tempReceiverQueue.size() > 0) {
      Receiver receiver=(Receiver)_tempReceiverQueue.take();
      Token token=_receiversAndTokensToSendTo.get(receiver);
      if (token != null) {
        _tokens.put(new Object[]{receiver,token});
        _tokenCount++;
        sendQMTokenEvent((Actor)receiver.getContainer().getContainer(),0,_tokenCount,EventType.RECEIVED);
      }
    }
    _receiversAndTokensToSendTo.clear();
  }
  if (_tokens.size() > 0 && (_nextTimeFree == null || currentTime.compareTo(_nextTimeFree) >= 0)) {
    _scheduleRefire();
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * If there are still tokens in the queue and a token has been produced in the fire, schedule a refiring.
 */
public boolean postfire() throws IllegalActionException {
  Time currentTime=getDirector().getModelTime();
  if (_nextTimeFree != null && _tokens.size() > 0 && currentTime.compareTo(_nextTimeFree) == 0) {
    _tokens.take();
    _tokenCount--;
    sendQMTokenEvent(null,0,_tokenCount,EventType.RECEIVED);
  }
  if ((getDirector() instanceof FixedPointDirector) && _receiversAndTokensToSendTo != null) {
    while (_tempReceiverQueue.size() > 0) {
      Receiver receiver=(Receiver)_tempReceiverQueue.take();
      Token token=_receiversAndTokensToSendTo.get(receiver);
      if (token != null) {
        _tokens.put(new Object[]{receiver,token});
        _tokenCount++;
        sendQMTokenEvent((Actor)receiver.getContainer().getContainer(),0,_tokenCount,EventType.RECEIVED);
      }
    }
  }
  if (_tokens.size() > 0 && (_nextTimeFree == null || currentTime.compareTo(_nextTimeFree) >= 0)) {
    _scheduleRefire();
  }
  _receiversAndTokensToSendTo.clear();
  return super.postfire();
}
Program: 73040
Project: 73040
Buggy source:
/** 
 * Dispose the current execution. 
 */
public void reset(){
  this.state=State.POSTFIRE_END_PREFIRE_BEGIN;
  currentStateEvent=createMetroIIEvent("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Dispose the current execution. 
 */
public void reset(){
  _state=State.POSTFIRE_END_PREFIRE_BEGIN;
  _currentStateEvent=_createMetroIIEvent("String_Node_Str");
}
Program: 73041
Project: 73041
Buggy source:
/** 
 * Construct a basic wrapper.
 * @param actor The actor
 */
public MetroIIActorBasicWrapper(Actor actor){
  this.actor=actor;
  this.state=State.POSTFIRE_END_PREFIRE_BEGIN;
  currentStateEvent=createMetroIIEvent("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Construct a basic wrapper.
 * @param actor The actor
 */
public MetroIIActorBasicWrapper(Actor actor){
  this._actor=actor;
  reset();
}
Program: 73042
Project: 73042
Buggy source:
/** 
 * Stop and dispose any associated thread. 
 */
@Override public void reset(){
  if (state == State.FIRING) {
    eventIterator.dispose();
    actor.stop();
  }
}

Fixed version (ground truth):
/** 
 * Stop and dispose any associated thread. 
 */
@Override public void reset(){
  if (_state == State.FIRING) {
    _eventIterator.dispose();
    _actor.stop();
  }
}
Program: 73043
Project: 73043
Buggy source:
/** 
 * Start or resume the execution of an actor. The execution means  calling prefire(), getfire(), and postfire(). The  execution of getfire() is encapsulated in a thread (implemented  in YieldAdapter).  The thread pauses when getfire() yield-returns a list of MetroII  events. 
 * @param metroIIEventList the list of MetroII events getfire() returns. 
 */
@Override public void startOrResume(LinkedList<Builder> metroIIEventList) throws IllegalActionException {
}

Fixed version (ground truth):
/** 
 * Start or resume the execution of an actor. The execution means  calling prefire(), getfire(), and postfire(). The  execution of getfire() is encapsulated in a thread (implemented  in YieldAdapter @see net.jimblackler.Utils.YieldAdapter).  The thread pauses when getfire() yield-returns a list of MetroII  events. 
 * @param metroIIEventList the list of MetroII events getfire() returns. 
 */
@Override public void startOrResume(LinkedList<Builder> metroIIEventList) throws IllegalActionException {
}
Program: 73044
Project: 73044
Buggy source:
/** 
 * Construct a Actor-Thread pair.
 * @param actor The actor
 */
public MetroIIActorGeneralWrapper(Actor actor){
  super(actor);
  this.eventIterator=null;
}

Fixed version (ground truth):
/** 
 * Construct a Actor-Thread pair.
 * @param actor The actor
 */
public MetroIIActorGeneralWrapper(Actor actor){
  super(actor);
  this._eventIterator=null;
}
Program: 73045
Project: 73045
Buggy source:
/** 
 * Schedule an actor for execution on a ResourceScheduler. If the actor can execute this method returns true. If resources are not available this  method returns false. 
 * @param actor The actor.
 * @param timestamp The time the actor requests to be scheduled.
 * @param executionTime The execution Time for this event. 
 * @return True if actor was scheduled and can be fired.
 * @exception IllegalActionException Thrown if parameters cannot be read, actor cannot bescheduled or container cannot be fired at future time.
 */
protected boolean _schedule(Actor actor,Time timestamp) throws IllegalActionException {
  _resourceBusy=false;
  ResourceSchedulerInterface scheduler=_getScheduler(actor);
  Time time=null;
  Boolean finished=true;
  if (timestamp == null) {
    timestamp=getModelTime();
  }
  if (scheduler != null) {
    double deadline=_getDeadline(actor,timestamp);
    time=(scheduler).schedule(actor,getEnvironmentTime(),deadline,_getExecutionTime(actor));
    finished=_actorFinished(actor);
    if (time != null && time.getDoubleValue() > 0.0) {
      CompositeActor container=(CompositeActor)((Attribute)scheduler).getContainer();
      container.getDirector().fireContainerAt(getEnvironmentTime().add(time));
    }
  }
 else   if (isEmbedded()) {
    return ((CompositeActor)(((CompositeActor)getContainer())).getContainer()).getDirector()._schedule(actor,timestamp);
  }
  return _resourceBusy=(time == null || finished);
}

Fixed version (ground truth):
/** 
 * Schedule an actor for execution on a ResourceScheduler. If the actor can execute this method returns true. If resources are not available this  method returns false. 
 * @param actor The actor.
 * @param timestamp The time the actor requests to be scheduled.
 * @param executionTime The execution Time for this event. 
 * @return True if actor was scheduled and can be fired.
 * @exception IllegalActionException Thrown if parameters cannot be read, actor cannot bescheduled or container cannot be fired at future time.
 */
protected boolean _schedule(Actor actor,Time timestamp) throws IllegalActionException {
  ResourceSchedulerInterface scheduler=_getScheduler(actor);
  Time time=null;
  Boolean finished=true;
  if (timestamp == null) {
    timestamp=getModelTime();
  }
  if (scheduler != null) {
    double deadline=_getDeadline(actor,timestamp);
    time=(scheduler).schedule(actor,getEnvironmentTime(),deadline,_getExecutionTime(actor));
    finished=_actorFinished(actor);
    if (time != null && time.getDoubleValue() > 0.0) {
      CompositeActor container=(CompositeActor)((Attribute)scheduler).getContainer();
      container.getDirector().fireContainerAt(getEnvironmentTime().add(time));
    }
  }
 else   if (isEmbedded()) {
    return ((CompositeActor)(((CompositeActor)getContainer())).getContainer()).getDirector()._schedule(actor,timestamp);
  }
  return (time == null || finished);
}
Program: 73047
Project: 73047
Buggy source:
/** 
 * Add a pure event to the queue of pure events.
 * @param actor Actor to fire.
 * @param time Time the actor should be fired at.
 * @param index Microstep the actor should be fired at.
 * @return The time the actor requested to be refired at.
 * @exception IllegalActionException If firing of the container doesn't succeed.
 */
public Time fireAt(Actor actor,Time time,int index) throws IllegalActionException {
  if (actor == this.getContainer()) {
    fireContainerAt(time);
    return time;
  }
  int newIndex=index;
  if (_currentLogicalTime != null && _currentLogicalTime.compareTo(time) == 0 && index <= getIndex()) {
    if (!resourceBusy()) {
      newIndex=Math.max(getIndex(),index) + 1;
    }
  }
  if (_isInitializing) {
    _currentSourceTimestamp=time;
  }
  _pureEvents.put(new PtidesEvent(actor,null,time,newIndex,0,_zeroTime,_currentSourceTimestamp));
  _currentSourceTimestamp=null;
  Time environmentTime=super.getEnvironmentTime();
  if (environmentTime.compareTo(time) <= 0) {
    fireContainerAt(time,1);
  }
  return time;
}

Fixed version (ground truth):
/** 
 * Add a pure event to the queue of pure events.
 * @param actor Actor to fire.
 * @param time Time the actor should be fired at.
 * @param index Microstep the actor should be fired at.
 * @return The time the actor requested to be refired at.
 * @exception IllegalActionException If firing of the container doesn't succeed.
 */
public Time fireAt(Actor actor,Time time,int index) throws IllegalActionException {
  if (actor == this.getContainer()) {
    fireContainerAt(time);
    return time;
  }
  int newIndex=index;
  if (_currentLogicalTime != null && _currentLogicalTime.compareTo(time) == 0 && index <= getIndex()) {
    if (((CompositeActor)actor).getDirector().scheduleContainedActors()) {
      newIndex=Math.max(getIndex(),index) + 1;
    }
  }
  if (_isInitializing) {
    _currentSourceTimestamp=time;
  }
  _pureEvents.put(new PtidesEvent(actor,null,time,newIndex,0,_zeroTime,_currentSourceTimestamp));
  _currentSourceTimestamp=null;
  Time environmentTime=super.getEnvironmentTime();
  if (environmentTime.compareTo(time) <= 0) {
    fireContainerAt(time,1);
  }
  return time;
}
Program: 73048
Project: 73048
Buggy source:
/** 
 * Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.
 * @param container Container of the director.
 * @param name Name of this director.
 * @exception IllegalActionException If thedirector is not compatible with the specified container.
 * @exception NameDuplicationException If the container not aCompositeActor and the name collides with an entity in the container.
 */
public SchedulerDirector(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
}

Fixed version (ground truth):
/** 
 * Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.
 * @param container Container of the director.
 * @param name Name of this director.
 * @exception IllegalActionException If thedirector is not compatible with the specified container.
 * @exception NameDuplicationException If the container not aCompositeActor and the name collides with an entity in the container.
 */
public SchedulerDirector(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  _resourceScheduling=false;
}
Program: 73049
Project: 73049
Buggy source:
/** 
 * Return true if next actor in list of fire requests was scheduled and can execute.
 * @return true If next actor can execute.
 * @exception IllegalActionExcepiton If request to resource scheduler fails.
 */
public boolean scheduleContainedActors() throws IllegalActionException {
  RefireRequest request=_fireAtRequests.peek();
  return _schedule(request.actor,getModelTime());
}

Fixed version (ground truth):
/** 
 * Return true if next actor in list of fire requests was scheduled and can execute.
 * @return true If next actor can execute.
 * @exception IllegalActionExcepiton If request to resource scheduler fails.
 */
public boolean scheduleContainedActors() throws IllegalActionException {
  RefireRequest request=_fireAtRequests.peek();
  if (request == null) {
    return true;
  }
  return _schedule(request.actor,getModelTime());
}
Program: 73050
Project: 73050
Buggy source:
/** 
 * Iterate the specified actor once.
 * @return True if either prefire() returns falseor postfire() returns true.
 * @throws IllegalActionException If the actor throws it.
 */
protected boolean _iterateActorOnce(Actor actor) throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str" + actor.getFullName() + "String_Node_Str");
  }
  FiringsRecordable firingsRecordable=null;
  if (actor instanceof FiringsRecordable) {
    firingsRecordable=(FiringsRecordable)actor;
  }
  if (firingsRecordable != null) {
    firingsRecordable.recordFiring(FiringEvent.BEFORE_PREFIRE);
  }
  boolean result=true;
  if (actor.prefire()) {
    if (firingsRecordable != null) {
      firingsRecordable.recordFiring(FiringEvent.AFTER_PREFIRE);
      firingsRecordable.recordFiring(FiringEvent.BEFORE_FIRE);
    }
    actor.fire();
    if (firingsRecordable != null) {
      firingsRecordable.recordFiring(FiringEvent.AFTER_FIRE);
      firingsRecordable.recordFiring(FiringEvent.BEFORE_POSTFIRE);
    }
    result=actor.postfire();
    if (firingsRecordable != null) {
      firingsRecordable.recordFiring(FiringEvent.AFTER_POSTFIRE);
    }
  }
 else   if (firingsRecordable != null) {
    firingsRecordable.recordFiring(FiringEvent.AFTER_PREFIRE);
  }
  if (!result) {
    if (_debugging) {
      _debug(actor.getFullName() + "String_Node_Str");
    }
    _actorsFinishedExecution.add(actor);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Iterate the specified actor once.
 * @return True if either prefire() returns falseor postfire() returns true.
 * @throws IllegalActionException If the actor throws it.
 */
protected boolean _iterateActorOnce(Actor actor) throws IllegalActionException {
  FiringsRecordable firingsRecordable=null;
  if (actor instanceof FiringsRecordable) {
    firingsRecordable=(FiringsRecordable)actor;
  }
  if (firingsRecordable != null) {
    firingsRecordable.recordFiring(FiringEvent.BEFORE_PREFIRE);
  }
  boolean result=true;
  if (actor.prefire()) {
    if (firingsRecordable != null) {
      firingsRecordable.recordFiring(FiringEvent.AFTER_PREFIRE);
      firingsRecordable.recordFiring(FiringEvent.BEFORE_FIRE);
    }
    actor.fire();
    if (firingsRecordable != null) {
      firingsRecordable.recordFiring(FiringEvent.AFTER_FIRE);
      firingsRecordable.recordFiring(FiringEvent.BEFORE_POSTFIRE);
    }
    result=actor.postfire();
    if (firingsRecordable != null) {
      firingsRecordable.recordFiring(FiringEvent.AFTER_POSTFIRE);
    }
  }
 else   if (firingsRecordable != null) {
    firingsRecordable.recordFiring(FiringEvent.AFTER_PREFIRE);
  }
  if (!result) {
    if (_debugging) {
      _debug(actor.getFullName() + "String_Node_Str");
    }
    _actorsFinishedExecution.add(actor);
  }
  return result;
}
Program: 73052
Project: 73052
Buggy source:
/** 
 * Add a pure event to the queue of pure events.
 * @param actor Actor to fire.
 * @param time Time the actor should be fired at.
 * @param index Microstep the actor should be fired at.
 * @return The time the actor requested to be refired at.
 * @exception IllegalActionException If firing of the container doesn't succeed.
 */
public Time fireAt(Actor actor,Time time,int index) throws IllegalActionException {
  if (actor == this.getContainer()) {
    fireContainerAt(time);
    return time;
  }
  int newIndex=index;
  if (_currentLogicalTime != null && _currentLogicalTime.compareTo(time) == 0 && index <= getIndex()) {
    if (((CompositeActor)actor).getDirector().scheduleContainedActors()) {
      newIndex=Math.max(getIndex(),index) + 1;
    }
  }
  if (_isInitializing) {
    _currentSourceTimestamp=time;
  }
  _pureEvents.put(new PtidesEvent(actor,null,time,newIndex,0,_zeroTime,_currentSourceTimestamp));
  _currentSourceTimestamp=null;
  Time environmentTime=super.getEnvironmentTime();
  if (environmentTime.compareTo(time) <= 0) {
    fireContainerAt(time,1);
  }
  return time;
}

Fixed version (ground truth):
/** 
 * Add a pure event to the queue of pure events.
 * @param actor Actor to fire.
 * @param time Time the actor should be fired at.
 * @param index Microstep the actor should be fired at.
 * @return The time the actor requested to be refired at.
 * @exception IllegalActionException If firing of the container doesn't succeed.
 */
public Time fireAt(Actor actor,Time time,int index) throws IllegalActionException {
  if (actor == this.getContainer()) {
    fireContainerAt(time);
    return time;
  }
  int newIndex=index;
  if (_currentLogicalTime != null && _currentLogicalTime.compareTo(time) == 0 && index <= getIndex()) {
    if (!(actor instanceof CompositeActor) || ((CompositeActor)actor).getDirector().scheduleContainedActors()) {
      newIndex=Math.max(getIndex(),index) + 1;
    }
  }
  if (_isInitializing) {
    _currentSourceTimestamp=time;
  }
  _pureEvents.put(new PtidesEvent(actor,null,time,newIndex,0,_zeroTime,_currentSourceTimestamp));
  _currentSourceTimestamp=null;
  Time environmentTime=super.getEnvironmentTime();
  if (environmentTime.compareTo(time) <= 0) {
    fireContainerAt(time,1);
  }
  return time;
}
Program: 73053
Project: 73053
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there).
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Director newObject=(Director)super.clone(workspace);
  newObject._actorsFinishedExecution=null;
  newObject._initializables=null;
  newObject._startTime=null;
  newObject._stopTime=null;
  newObject._zeroTime=new Time(newObject);
  newObject._executionTimes=new HashMap<Actor,Time>();
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there).
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Director newObject=(Director)super.clone(workspace);
  newObject._actorsFinishedExecution=null;
  newObject._initializables=null;
  newObject._startTime=null;
  newObject._stopTime=null;
  newObject._zeroTime=new Time(newObject);
  newObject._executionTimes=new HashMap<Actor,Time>();
  newObject._resourceSchedulers=new ArrayList<ResourceSchedulerInterface>();
  return newObject;
}
Program: 73054
Project: 73054
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there).
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Director newObject=(Director)super.clone(workspace);
  newObject._actorsFinishedExecution=null;
  newObject._initializables=null;
  newObject._startTime=null;
  newObject._stopTime=null;
  newObject._zeroTime=new Time(newObject);
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there).
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Director newObject=(Director)super.clone(workspace);
  newObject._actorsFinishedExecution=null;
  newObject._initializables=null;
  newObject._startTime=null;
  newObject._stopTime=null;
  newObject._zeroTime=new Time(newObject);
  newObject._executionTimes=new HashMap<Actor,Time>();
  return newObject;
}
Program: 73055
Project: 73055
Buggy source:
/** 
 * Call requestFinish() on all receivers.
 */
private void _requestFinishOnReceivers(){
  CompositeActor container=(CompositeActor)getContainer();
  Iterator actors=container.deepEntityList().iterator();
  Iterator actorPorts;
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    actorPorts=actor.inputPortList().iterator();
    while (actorPorts.hasNext()) {
      IOPort port=(IOPort)actorPorts.next();
      Receiver[][] receivers=port.getReceivers();
      for (int i=0; i < receivers.length; i++) {
        for (int j=0; j < receivers[i].length; j++) {
          if (receivers[i][j] instanceof ProcessReceiver) {
            ((ProcessReceiver)receivers[i][j]).requestFinish();
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Call requestFinish() on all receivers.
 */
protected void _requestFinishOnReceivers(){
  CompositeActor container=(CompositeActor)getContainer();
  Iterator actors=container.deepEntityList().iterator();
  Iterator actorPorts;
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    actorPorts=actor.inputPortList().iterator();
    while (actorPorts.hasNext()) {
      IOPort port=(IOPort)actorPorts.next();
      Receiver[][] receivers=port.getReceivers();
      for (int i=0; i < receivers.length; i++) {
        for (int j=0; j < receivers[i].length; j++) {
          if (receivers[i][j] instanceof ProcessReceiver) {
            ((ProcessReceiver)receivers[i][j]).requestFinish();
          }
        }
      }
    }
  }
}
Program: 73056
Project: 73056
Buggy source:
/** 
 * Update the MetroII event list.
 * @param metroIIEventList MetroII event list
 */
public void resolve(Iterable<Event.Builder> metroIIEventList);

Fixed version (ground truth):
/** 
 * Update the MetroII events in the specified list
 * @param metroIIEventList A list of MetroII events to be updated
 */
public void resolve(Iterable<Event.Builder> metroIIEventList);
Program: 73057
Project: 73057
Buggy source:
/** 
 * Construct a mapping constraint solver of given size.
 * @param size The maximum number of allowed events.
 */
public MappingConstraintSolver(int size){
  _mapping=new int[size][size];
  _size=size;
  for (int i=0; i < _size; i++) {
    for (int j=0; j < _size; j++) {
      _mapping[i][j]=0;
    }
  }
  _currentMAXID=0;
}

Fixed version (ground truth):
/** 
 * Construct a mapping constraint solver of given size.
 * @param size The maximum number of allowed events.
 */
public MappingConstraintSolver(int size){
  _mapping=new int[size][size];
  _size=size;
  _initialize();
}
Program: 73058
Project: 73058
Buggy source:
/** 
 * Implement the MetroIIActorInterface. prefire(), fire() and postfire() are wrapped  in startOrResume(). The execution of startOrResume() can be seen as  follows:  <ol> <li> 1. Propose MetroII event POSTFIRE_END_PREFIRE_BEGIN </li> <li> 2. Check if POSTFIRE_END_PREFIRE_BEGIN is Notified. If not, go to 1 </li> <li> 3. prefire() </li> <li> 4. Propose MetroII event PREFIRE_END_FIRE_BEGIN </li> <li> 5. Check if PREFIRE_END_FIRE_BEGIN is Notified. If not, go to 4 </li> <li> 6. fire() </li> <li> 7. Propose MetroII event FIRE_END_POSTFIRE_BEGIN </li> <li> 8. Check if FIRE_END_POSTFIRE_BEGIN is Notified. If not, go to 4 </li> <li> 9. postfire() </li> </ol>
 */
@Override public void startOrResume(LinkedList<Builder> metroIIEventList) throws IllegalActionException {
}

Fixed version (ground truth):
/** 
 * The functions prefire(), fire() and postfire()  are wrapped in startOrResume() as follows:  <ol> <li> Propose MetroII event POSTFIRE_END_PREFIRE_BEGIN and wait for  the event being notified</li> <li> prefire() </li> <li> Propose MetroII event PREFIRE_END_FIRE_BEGIN and wait for the  event being notified</li> <li> fire() </li> <li> Propose MetroII event FIRE_END_POSTFIRE_BEGIN and wait for the  the event being notified</li> <li> postfire() </li> </ol> where 'wait' means checking the status of MetroII event. If notified,  continue execution, otherwise proposing the same event again.
 * @param metroIIEventList A list of MetroII events. 
 */
@Override public void startOrResume(LinkedList<Builder> metroIIEventList) throws IllegalActionException {
}
Program: 73059
Project: 73059
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 (iterationsValue > 0 && _iterationCount >= iterationsValue) {
    _iterationCount=0;
    for (    MetroIIActorInterface actor : _actorList) {
      actor.close();
    }
    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 (    MetroIIActorInterface actor : _actorList) {
      actor.reset();
    }
    return false;
  }
  return true;
}
Program: 73060
Project: 73060
Buggy source:
/** 
 * Construct a director in the given container with the given name.  The container argument must not be null, or a NullPointerException will be thrown.  If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.
 * @param container Container of the director.
 * @param name Name of this director.
 * @exception IllegalActionException If the director is not compatiblewith the specified container.  May be thrown in a derived class.
 * @exception NameDuplicationException If the container is not aCompositeActor and the name collides with an entity in the container.
 */
public MetroIIDirector(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  _initializeParameters();
  initialize();
}

Fixed version (ground truth):
/** 
 * Construct a director in the given container with the given name.  The container argument must not be null, or a NullPointerException will be thrown.  If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.
 * @param container Container of the director.
 * @param name Name of this director.
 * @exception IllegalActionException If the director is not compatiblewith the specified container.  May be thrown in a derived class.
 * @exception NameDuplicationException If the container is not aCompositeActor and the name collides with an entity in the container.
 */
public MetroIIDirector(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  _actorList=new LinkedList<MetroIIActorInterface>();
  _mappingConstraintSolver=new MappingConstraintSolver(_maxEvent);
  _initializeParameters();
  initialize();
}
Program: 73061
Project: 73061
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 {
  if (!_stopRequested) {
    LinkedList<Event.Builder> globalMetroIIEventList=new LinkedList<Event.Builder>();
    System.out.println("String_Node_Str" + Integer.toString(_iterationCount) + "String_Node_Str");
    System.out.println("String_Node_Str");
    for (    MetroIIActorInterface actor : _actorList) {
      LinkedList<Event.Builder> metroIIEventList=new LinkedList<Event.Builder>();
      actor.startOrResume(metroIIEventList);
      globalMetroIIEventList.addAll(metroIIEventList);
    }
    for (    Event.Builder builder : globalMetroIIEventList) {
      System.out.format("String_Node_Str",builder.getName(),builder.getStatus());
    }
    System.out.println("String_Node_Str");
    _mappingConstraintSolver.resolve(globalMetroIIEventList);
    for (    Event.Builder mtb : globalMetroIIEventList) {
      System.out.format("String_Node_Str",mtb.getName(),mtb.getStatus());
    }
  }
  if (_stopRequested) {
    for (    MetroIIActorInterface actor : _actorList) {
      actor.close();
    }
  }
}

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 {
  if (!_stopRequested) {
    LinkedList<Event.Builder> globalMetroIIEventList=new LinkedList<Event.Builder>();
    System.out.println("String_Node_Str" + Integer.toString(_iterationCount) + "String_Node_Str");
    System.out.println("String_Node_Str");
    for (    MetroIIActorInterface actor : _actorList) {
      LinkedList<Event.Builder> metroIIEventList=new LinkedList<Event.Builder>();
      actor.startOrResume(metroIIEventList);
      globalMetroIIEventList.addAll(metroIIEventList);
    }
    for (    Event.Builder builder : globalMetroIIEventList) {
      System.out.format("String_Node_Str",builder.getName(),builder.getStatus());
    }
    System.out.println("String_Node_Str");
    _mappingConstraintSolver.resolve(globalMetroIIEventList);
    for (    Event.Builder mtb : globalMetroIIEventList) {
      System.out.format("String_Node_Str",mtb.getName(),mtb.getStatus());
    }
  }
}
Program: 73062
Project: 73062
Buggy source:
/** 
 * Initialize the model controlled by this director. Call the  initialize() of super class and then wrap each actor that  is controlled by this director. This method should typically be invoked once per execution, after the preinitialization phase, but before any iteration. It may be invoked in the middle of an execution, if reinitialization is desired.  This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  Nameable container=getContainer();
  if (container instanceof CompositeActor) {
    Iterator<?> actors=((CompositeActor)container).deepEntityList().iterator();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      if (actor instanceof MetroIIEventHandler) {
        _actorList.add(new MetroIIActorGeneralWrapper(actor));
      }
 else {
        _actorList.add(new MetroIIActorBasicWrapper(actor));
      }
    }
  }
  _iterationCount=0;
}

Fixed version (ground truth):
/** 
 * Initialize the model controlled by this director. Call the  initialize() of super class and then wrap each actor that  is controlled by this director. This method should typically be invoked once per execution, after the preinitialization phase, but before any iteration. It may be invoked in the middle of an execution, if reinitialization is desired.  This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  Nameable container=getContainer();
  if (container instanceof CompositeActor) {
    Iterator<?> actors=((CompositeActor)container).deepEntityList().iterator();
    _actorList.clear();
    while (actors.hasNext()) {
      Actor actor=(Actor)actors.next();
      if (actor instanceof MetroIIEventHandler) {
        _actorList.add(new MetroIIActorGeneralWrapper(actor));
      }
 else {
        _actorList.add(new MetroIIActorBasicWrapper(actor));
      }
    }
  }
  _iterationCount=0;
}
Program: 73065
Project: 73065
Buggy source:
/** 
 * Invoke the wrapup() of the super class.  Leave and quit OpenModelica environment. OMCProxy and OMCLogger objects are reset.
 * @exception IllegalActionException If the wrapup() ofOpenModelica actor throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  try {
    _omcProxy.quit();
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _omcProxy=null;
    _omcLogger=null;
  }
 catch (  ConnectException ex) {
    String loggerInfo="String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    throw new IllegalActionException(loggerInfo);
  }
}

Fixed version (ground truth):
/** 
 * Invoke the wrapup() of the super class.  Leave and quit OpenModelica environment.
 * @exception IllegalActionException If the wrapup() ofOpenModelica actor throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  try {
    _omcProxy.quit();
    if (_debugging) {
      _debug("String_Node_Str");
    }
  }
 catch (  ConnectException ex) {
    String loggerInfo="String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    throw new IllegalActionException(loggerInfo);
  }
}
Program: 73066
Project: 73066
Buggy source:
/** 
 * Invoke the preinitialize() of the super class.  Preinitialize the OpenModelica actor and initialize the OpenModelica Compiler(OMC).
 * @exception IllegalActionException If the preinitialize() ofone of the associated actors throws it.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  try {
    String omcResultFilePath=null;
    String temp=System.getProperty("String_Node_Str");
    String username=System.getenv("String_Node_Str");
    if (username == null)     omcResultFilePath=temp + "String_Node_Str";
 else     omcResultFilePath=temp + "String_Node_Str" + username+ "String_Node_Str";
    File userFile=new File(omcResultFilePath);
    if (!userFile.exists())     new File(omcResultFilePath).mkdirs();
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _omcProxy.initServer();
  }
 catch (  ConnectException ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Invoke the preinitialize() of the super class.  Preinitialize the OpenModelica actor and initialize the OpenModelica Compiler(OMC).
 * @exception IllegalActionException If the preinitialize() ofone of the associated actors throws it.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  try {
    String omcResultFilePath=null;
    String temp=System.getProperty("String_Node_Str");
    String username=System.getenv("String_Node_Str");
    if (username == null)     omcResultFilePath=temp + "String_Node_Str";
 else     omcResultFilePath=temp + "String_Node_Str" + username+ "String_Node_Str";
    File userFile=new File(omcResultFilePath);
    if (!userFile.exists())     new File(omcResultFilePath).mkdirs();
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _omcLogger=OMCLogger.getInstance();
    _omcProxy=OMCProxy.getInstance();
    _omcProxy.initServer();
  }
 catch (  ConnectException ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
}
Program: 73067
Project: 73067
Buggy source:
/** 
 * Evaluate the expression and send its result to the output.
 * @exception IllegalActionException If the evaluation of the expressiontriggers it, or the evaluation yields a null result, or the evaluation yields an incompatible type, or if there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  Director director=getDirector();
  if (director == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  try {
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _simulate();
    _plot();
  }
 catch (  Throwable throwable) {
    throw new IllegalActionException(this,throwable,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Evaluate the expression and send its result to the output.
 * @exception IllegalActionException If the evaluation of the expressiontriggers it, or the evaluation yields a null result, or the evaluation yields an incompatible type, or if there is no director.
 */
public void fire() throws IllegalActionException {
  super.fire();
  Director director=getDirector();
  if (director == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  try {
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _omcProxy=OMCProxy.getInstance();
    _omcLogger=OMCLogger.getInstance();
    _simulate();
    _plot();
  }
 catch (  Throwable throwable) {
    throw new IllegalActionException(this,throwable,"String_Node_Str");
  }
}
Program: 73068
Project: 73068
Buggy source:
/** 
 * Construct an OpenModelica Compiler(OMC) proxy. This constructor has no parameter.  This private Constructor prevents other class from instantiating. 
 */
private OMCProxy(){
}

Fixed version (ground truth):
/** 
 * Construct an OpenModelica Compiler(OMC) proxy. This constructor has no parameter.  This private Constructor prevents other class from instantiating. 
 */
private OMCProxy(){
  _omcLogger=OMCLogger.getInstance();
}
Program: 73070
Project: 73070
Buggy source:
/** 
 * Initialize the communication with the OpenModelica compiler(OMC).
 * @exception ConnectException If we're unable to start communicating withthe server.
 * @throws InterruptedException 
 */
public synchronized void initServer() throws ConnectException {
  _os=getOs();
  String strDate="String_Node_Str";
  Date date=new Date();
  SimpleDateFormat timeFormat=new SimpleDateFormat("String_Node_Str");
  strDate=timeFormat.format(date);
  _corbaSession=strDate;
  File f=new File(_getPathToObject());
  String stringifiedObjectReference=null;
  if (!f.exists()) {
    String loggerInfo="String_Node_Str";
    _omcLoggerInstance.getInfo(loggerInfo);
    _startServer();
  }
 else {
    String loggerInfo="String_Node_Str";
    _omcLoggerInstance.getInfo(loggerInfo);
  }
  stringifiedObjectReference=_readObjectFromFile();
  _setupOmcc(stringifiedObjectReference);
  hasInitialized=true;
}

Fixed version (ground truth):
/** 
 * Initialize the communication with the OpenModelica compiler(OMC).
 * @exception ConnectException If we're unable to start communicating withthe server.
 * @throws InterruptedException 
 */
public synchronized void initServer() throws ConnectException {
  _os=getOs();
  String strDate="String_Node_Str";
  Date date=new Date();
  SimpleDateFormat timeFormat=new SimpleDateFormat("String_Node_Str");
  strDate=timeFormat.format(date);
  _corbaSession=strDate;
  File f=new File(_getPathToObject());
  String stringifiedObjectReference=null;
  if (!f.exists()) {
    String loggerInfo="String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    _startServer();
  }
 else {
    String loggerInfo="String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
  stringifiedObjectReference=_readObjectFromFile();
  _setupOmcc(stringifiedObjectReference);
  hasInitialized=true;
}
Program: 73071
Project: 73071
Buggy source:
/** 
 * Return the path to the OMC CORBA object that is stored on a disk.
 */
private String _getPathToObject(){
  String fileName=null;
  String username=System.getenv("String_Node_Str");
  String temp=System.getProperty("String_Node_Str");
switch (OMCProxy.getOs()) {
case UNIX:
    if (username == null) {
      username="String_Node_Str";
    }
  if (_corbaSession == null || _corbaSession.equalsIgnoreCase("String_Node_Str")) {
    fileName=temp + "String_Node_Str" + username+ "String_Node_Str";
  }
 else {
    fileName=temp + "String_Node_Str" + username+ "String_Node_Str"+ "String_Node_Str"+ _corbaSession;
  }
break;
case WINDOWS:
if (_corbaSession == null || _corbaSession.equalsIgnoreCase("String_Node_Str")) {
fileName=temp + "String_Node_Str";
}
 else {
fileName=temp + "String_Node_Str" + "String_Node_Str"+ _corbaSession;
}
break;
case MAC:
String macUsername=System.getenv("String_Node_Str");
if (macUsername == null) {
macUsername="String_Node_Str";
}
if (_corbaSession == null || _corbaSession.equalsIgnoreCase("String_Node_Str")) {
fileName=temp + "String_Node_Str" + macUsername+ "String_Node_Str";
}
 else {
fileName=temp + "String_Node_Str" + macUsername+ "String_Node_Str"+ "String_Node_Str"+ _corbaSession;
}
break;
}
String loggerInfo="String_Node_Str" + fileName + "String_Node_Str";
_omcLoggerInstance.getInfo(loggerInfo);
return fileName;
}

Fixed version (ground truth):
/** 
 * Return the path to the OMC CORBA object that is stored on a disk.
 */
private String _getPathToObject(){
  String fileName=null;
  String username=System.getenv("String_Node_Str");
  String temp=System.getProperty("String_Node_Str");
switch (OMCProxy.getOs()) {
case UNIX:
    if (username == null) {
      username="String_Node_Str";
    }
  if (_corbaSession == null || _corbaSession.equalsIgnoreCase("String_Node_Str")) {
    fileName=temp + "String_Node_Str" + username+ "String_Node_Str";
  }
 else {
    fileName=temp + "String_Node_Str" + username+ "String_Node_Str"+ "String_Node_Str"+ _corbaSession;
  }
break;
case WINDOWS:
if (_corbaSession == null || _corbaSession.equalsIgnoreCase("String_Node_Str")) {
fileName=temp + "String_Node_Str";
}
 else {
fileName=temp + "String_Node_Str" + "String_Node_Str"+ _corbaSession;
}
break;
case MAC:
String macUsername=System.getenv("String_Node_Str");
if (macUsername == null) {
macUsername="String_Node_Str";
}
if (_corbaSession == null || _corbaSession.equalsIgnoreCase("String_Node_Str")) {
fileName=temp + "String_Node_Str" + macUsername+ "String_Node_Str";
}
 else {
fileName=temp + "String_Node_Str" + macUsername+ "String_Node_Str"+ "String_Node_Str"+ _corbaSession;
}
break;
}
String loggerInfo="String_Node_Str" + fileName + "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
return fileName;
}
Program: 73073
Project: 73073
Buggy source:
/** 
 * Leave and quit OpenModelica environment.
 * @exception ConnectException If quit command couldn'tbe sent to OMC.
 */
public void quit() throws ConnectException {
  if (hasInitialized=true) {
    sendCommand("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Leave and quit OpenModelica environment. Deallocate OMCProxy and OMCLogger objects.
 * @exception ConnectException If quit command couldn'tbe sent to OMC.
 */
public void quit() throws ConnectException {
  if (hasInitialized=true) {
    sendCommand("String_Node_Str");
    _omcProxyInstance=null;
    _omcLogger=null;
  }
}
Program: 73074
Project: 73074
Buggy source:
/** 
 * Create an instance of OMCProxy in order to provide a global point of access to this instance. It provides a unique source of OMCProxy instance.
 */
public static OMCProxy getInstance(){
  if (_omcProxyInstance == null) {
    _omcProxyInstance=new OMCProxy();
  }
  return _omcProxyInstance;
}

Fixed version (ground truth):
/** 
 * Create an instance of OMCProxy object in order to provide a global point of access to the instance. It provides a unique source of OMCProxy instance.
 */
public static OMCProxy getInstance(){
  if (_omcProxyInstance == null) {
    _omcProxyInstance=new OMCProxy();
  }
  return _omcProxyInstance;
}
Program: 73075
Project: 73075
Buggy source:
/** 
 * Invoke the wrapup() of the super class.  Leave and quit OpenModelica environment.
 * @exception IllegalActionException If the wrapup() ofOpenModelica actor throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  try {
    _omcCommand=OMCCommand.getInstance();
    _omcCommand.quitServer();
    if (_debugging) {
      _debug("String_Node_Str");
    }
  }
 catch (  ConnectException ex) {
    String loggerInfo="String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    throw new IllegalActionException(loggerInfo);
  }
}

Fixed version (ground truth):
/** 
 * Invoke the wrapup() of the super class.  Leave and quit OpenModelica environment.
 * @exception IllegalActionException If the wrapup() ofOpenModelica actor throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  try {
    _omcProxy.quitServer();
    if (_debugging) {
      _debug("String_Node_Str");
    }
  }
 catch (  ConnectException ex) {
    String loggerInfo="String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    throw new IllegalActionException(loggerInfo);
  }
}
Program: 73076
Project: 73076
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there).
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  OpenModelicaDirector newObject=(OpenModelicaDirector)super.clone(workspace);
  try {
    newObject._omcCommand=OMCCommand.getInstance();
    newObject._omcLogger=OMCLogger.getInstance();
    newObject._omcProxy=OMCProxy.getInstance();
  }
 catch (  Throwable throwable) {
    throw new CloneNotSupportedException("String_Node_Str" + getFullName() + "String_Node_Str"+ throwable);
  }
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there).
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException Not thrown in this base class
 * @return The new Attribute.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  OpenModelicaDirector newObject=(OpenModelicaDirector)super.clone(workspace);
  try {
    newObject._omcLogger=OMCLogger.getInstance();
    newObject._omcProxy=OMCProxy.getInstance();
  }
 catch (  Throwable throwable) {
    throw new CloneNotSupportedException("String_Node_Str" + getFullName() + "String_Node_Str"+ throwable);
  }
  return newObject;
}