nus-yam/ex-repair huggingface dataset:
Program: 76514
Project: 76514
Buggy source:
/** 
 * This decreases the number of active threads in the compositeActor by 1. It also checks if the simulation has paused if a pause was requested. This method should be called only when an active thread that was registered using increaseActiveCount() is terminated.
 */
public synchronized void decreaseActiveCount(){
  _actorsActive--;
  _checkForDeadlock();
  if (_pauseRequested) {
    _checkForPause();
  }
}

Fixed version (ground truth):
/** 
 * Decrease the number of active processes under the control of  this director by 1. Also checks if the model is now paused if a pause was requested. This method should be called only when an active thread that was registered using increaseActiveCount() is terminated.
 */
public synchronized void decreaseActiveCount(){
  _actorsActive--;
  _checkForDeadlock();
  if (_pauseRequested) {
    _checkForPause();
  }
}
Program: 76515
Project: 76515
Buggy source:
/** 
 * This method should be called when a new thread corresponding to an actor is started in a simulation. This method is required for detection of deadlocks. The corresponding method decreaseActiveCount should be called when the thread is terminated.
 */
public synchronized void increaseActiveCount(){
  _actorsActive++;
}

Fixed version (ground truth):
/** 
 * This method should be called when a new thread corresponding to an actor is started in the model under the control of this director. This method is required for detection of deadlocks. The corresponding method decreaseActiveCount should be called when the thread is terminated.
 */
public synchronized void increaseActiveCount(){
  _actorsActive++;
}
Program: 76516
Project: 76516
Buggy source:
protected synchronized void _checkForDeadlock(){
  if (_actorsActive == 0) {
    _deadlock=true;
    notifyAll();
  }
  return;
}

Fixed version (ground truth):
/** 
 * Checks for deadlock. In the base class implementation it  returns true only if there are no active processes.
 */
protected synchronized void _checkForDeadlock(){
  if (_actorsActive == 0) {
    _deadlock=true;
    notifyAll();
  }
  return;
}
Program: 76517
Project: 76517
Buggy source:
protected synchronized void _checkForPause(){
  System.out.println("String_Node_Str" + "String_Node_Str");
  return;
}

Fixed version (ground truth):
/** 
 * Checks if all active processes are either blocked or paused. Should be overridden in derived classes.
 */
protected synchronized void _checkForPause(){
  System.out.println("String_Node_Str" + "String_Node_Str");
  return;
}
Program: 76518
Project: 76518
Buggy source:
/** 
 * Clone the director 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). The result is a new director with no container, no pending mutations, and no mutation listeners. FIXME: not finished.
 * @param ws The workspace for the cloned object.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 * @return The new CSPDirector.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  ProcessDirector newobj=(ProcessDirector)super.clone(ws);
  newobj._actorsActive=0;
  newobj._pausedReceivers=new LinkedList();
  return newobj;
}

Fixed version (ground truth):
/** 
 * Clone the director 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). The result is a new director with no container, no pending mutations, and no mutation listeners. The count of active proceses is zero  and it is not paused.
 * @param ws The workspace for the cloned object.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 * @return The new CSPDirector.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  ProcessDirector newobj=(ProcessDirector)super.clone(ws);
  newobj._actorsActive=0;
  newobj._pausedReceivers=new LinkedList();
  newobj._pauseRequested=false;
  newobj._threadList=new LinkedList();
  return newobj;
}
Program: 76519
Project: 76519
Buggy source:
/** 
 * Construct a thread to be used for the execution of the iteration methods of the actor.
 * @param actor The actor that needs to be executed.
 * @param director The director responsible for the execution of thisactor.
 * @param name The name of the thread.
 */
public ProcessThread(Actor actor,ProcessDirector director,String name){
  super(name);
  _actor=actor;
  _director=director;
  _manager=((CompositeActor)actor.getContainer()).getManager();
}

Fixed version (ground truth):
/** 
 * Construct a thread to be used for the execution of the iteration methods of the actor.
 * @param actor The actor that needs to be executed.
 * @param director The director responsible for the execution of thisactor.
 * @param name The name of the thread.
 */
public ProcessThread(Actor actor,ProcessDirector director,String name){
  super(name);
  _actor=actor;
  _director=director;
  _manager=((CompositeActor)((NamedObj)actor).getContainer()).getManager();
}
Program: 76520
Project: 76520
Buggy source:
/** 
 * Send a token to the receiver specified by the output port and channel number.
 */
public void send(int channelindex,Token token,double delay) throws InvalidStateException, IllegalActionException {
  if (delay < -1.0) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
  ODReceiver[][] farRec;
  try {
    workspace().getReadAccess();
    if (!isOutput()) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
    if (channelindex >= getWidth() || channelindex < 0) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    farRec=(ODReceiver[][])getRemoteReceivers();
    if (farRec == null || farRec[channelindex] == null)     return;
  }
  finally {
    workspace().doneReading();
  }
  for (int j=0; j < farRec[channelindex].length; j++) {
    double currentTime=((ODActor)getContainer()).getCurrentTime();
    farRec[channelindex][j].put(token,currentTime + delay);
  }
}

Fixed version (ground truth):
/** 
 * Send a token to the receiver specified by the output port and channel number.
 */
public void send(int channelindex,Token token,double delay) throws InvalidStateException, IllegalActionException {
  if (delay < -1.0) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
  }
  Receiver[][] farRec;
  try {
    workspace().getReadAccess();
    if (!isOutput()) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
    if (channelindex >= getWidth() || channelindex < 0) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    farRec=getRemoteReceivers();
    if (farRec == null || farRec[channelindex] == null) {
      return;
    }
    System.out.println("String_Node_Str" + "String_Node_Str");
    for (int j=0; j < farRec[channelindex].length; j++) {
      double currentTime=((ODActor)getContainer()).getCurrentTime();
      ((ODReceiver)farRec[channelindex][j]).put(token,currentTime + delay);
    }
  }
  finally {
    workspace().doneReading();
  }
}
Program: 76521
Project: 76521
Buggy source:
/** 
 * Return the receiver with the highest priority given that it has the lowest time stamp.
 */
public RcvrTimeTriple getHighestPriorityTriple(){
  double time=-1.0;
  double firstTime=-1.0;
  int maxPriority=0;
  int cnt=0;
  boolean rcvrNotFound=true;
  RcvrTimeTriple highPriorityTriple=null;
  while (rcvrNotFound) {
    if (cnt > _rcvrTimeTable.size()) {
      return highPriorityTriple;
    }
    RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.at(cnt);
    if (time == -1.0) {
      time=triple.getTime();
      firstTime=time;
      maxPriority=triple.getPriority();
      highPriorityTriple=triple;
    }
 else {
      time=triple.getTime();
    }
    if (time > firstTime) {
      rcvrNotFound=false;
    }
 else {
      if (maxPriority < triple.getPriority()) {
        maxPriority=triple.getPriority();
        highPriorityTriple=triple;
      }
    }
    cnt++;
  }
  return highPriorityTriple;
}

Fixed version (ground truth):
/** 
 * Return the receiver with the highest priority given that it has the lowest time stamp.
 */
public RcvrTimeTriple getHighestPriorityTriple(){
  double time=-1.0;
  double firstTime=-1.0;
  int maxPriority=0;
  int cnt=0;
  boolean rcvrNotFound=true;
  RcvrTimeTriple highPriorityTriple=null;
  while (rcvrNotFound) {
    if (cnt == _rcvrTimeTable.size()) {
      return highPriorityTriple;
    }
    RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.at(cnt);
    if (time == -1.0) {
      time=triple.getTime();
      firstTime=time;
      maxPriority=triple.getPriority();
      highPriorityTriple=triple;
    }
 else {
      time=triple.getTime();
    }
    if (time > firstTime) {
      rcvrNotFound=false;
    }
 else {
      if (maxPriority < triple.getPriority()) {
        maxPriority=triple.getPriority();
        highPriorityTriple=triple;
      }
    }
    cnt++;
  }
  return highPriorityTriple;
}
Program: 76522
Project: 76522
Buggy source:
/** 
 * Get the next token which has the minimum rcvrTime and highest priority. The returned token will have the lowest time stamp of  all pending tokens for this actor. If there are multiple tokens  with the lowest time stamp, then the returned token will also  have the highest priority.
 */
public Token getNextToken(){
  RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.first();
  ODReceiver lowestRcvr=(ODReceiver)triple.getReceiver();
  _currentTime=triple.getTime();
  _lastPort=(ODIOPort)triple.getReceiver().getContainer();
  Token token=lowestRcvr.get();
  if (token != null) {
    return token;
  }
 else {
    if (this.hasMinRcvrTime()) {
      return getNextToken();
    }
 else {
      RcvrTimeTriple priorityTriple=getHighestPriorityTriple();
      lowestRcvr=(ODReceiver)priorityTriple.getReceiver();
      lowestRcvr.setSimultaneousIgnore(true);
      token=lowestRcvr.get();
      _lastPort=(ODIOPort)lowestRcvr.getContainer();
      if (token != null) {
        return token;
      }
 else {
        return getNextToken();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Get the next token which has the minimum rcvrTime and highest priority. The returned token will have the lowest time stamp of  all pending tokens for this actor. If there are multiple tokens  with the lowest time stamp, then the returned token will also  have the highest priority.
 */
public Token getNextToken(){
  if (_rcvrTimeTable.size() == 0) {
    return null;
  }
  RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.first();
  ODReceiver lowestRcvr=(ODReceiver)triple.getReceiver();
  _currentTime=triple.getTime();
  _lastPort=(ODIOPort)triple.getReceiver().getContainer();
  Token token=lowestRcvr.get();
  if (token != null) {
    System.out.println("String_Node_Str");
    return token;
  }
 else {
    if (this.hasMinRcvrTime()) {
      return getNextToken();
    }
 else {
      RcvrTimeTriple priorityTriple=getHighestPriorityTriple();
      lowestRcvr=(ODReceiver)priorityTriple.getReceiver();
      lowestRcvr.setSimultaneousIgnore(true);
      token=lowestRcvr.get();
      _lastPort=(ODIOPort)lowestRcvr.getContainer();
      if (token != null) {
        System.out.println("String_Node_Str");
        return token;
      }
 else {
        return getNextToken();
      }
    }
  }
}
Program: 76523
Project: 76523
Buggy source:
/** 
 * Add the specified RcvrTimeTriple based on the _Receiver_. This method must be called after _removeRcvrTable() if  the RcvrTimeTriple table already conatains the triple specified in the argument.
 */
private void _addRcvrTriple(RcvrTimeTriple newTriple){
  int cnt=0;
  if (_rcvrTimeTable.size() == 0) {
    _rcvrTimeTable.insertAt(0,newTriple);
    return;
  }
  while (cnt < _rcvrTimeTable.size()) {
    RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.at(cnt);
    if (newTriple.getTime() <= triple.getTime()) {
      _rcvrTimeTable.insertAt(cnt,triple);
      cnt=_rcvrTimeTable.size();
    }
    cnt++;
  }
}

Fixed version (ground truth):
/** 
 * Add the specified RcvrTimeTriple based on the _Receiver_. This method must be called after _removeRcvrTable() if  the RcvrTimeTriple table already conatains the triple specified in the argument.
 */
private void _addRcvrTriple(RcvrTimeTriple newTriple){
  System.out.println("String_Node_Str");
  printRcvrTable();
  int cnt=0;
  boolean notAddedYet=true;
  if (_rcvrTimeTable.size() == 0) {
    String portName=newTriple.getReceiver().getContainer().getName();
    System.out.println(portName + "String_Node_Str" + cnt);
    _rcvrTimeTable.insertAt(0,newTriple);
    printRcvrTable();
    return;
  }
  System.out.println("String_Node_Str" + _rcvrTimeTable.size());
  while (cnt < _rcvrTimeTable.size()) {
    RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.at(cnt);
    String portName1=triple.getReceiver().getContainer().getName();
    System.out.println(portName1 + "String_Node_Str");
    String portName2=newTriple.getReceiver().getContainer().getName();
    System.out.println(portName2 + "String_Node_Str");
    System.out.println(portName1 + "String_Node_Str" + triple.getTime());
    System.out.println(portName2 + "String_Node_Str" + newTriple.getTime());
    if (newTriple.getTime() < triple.getTime()) {
      String portName=newTriple.getReceiver().getContainer().getName();
      System.out.println(portName + "String_Node_Str" + cnt);
      _rcvrTimeTable.insertAt(cnt,newTriple);
      cnt=_rcvrTimeTable.size();
      notAddedYet=false;
    }
    cnt++;
  }
  if (notAddedYet) {
    _rcvrTimeTable.insertLast(newTriple);
  }
  System.out.println("String_Node_Str");
  printRcvrTable();
}
Program: 76524
Project: 76524
Buggy source:
/** 
 * Get the next token which has the minimum rcvrTime and highest priority. The returned token will have the lowest time stamp of  all pending tokens for this actor. If there are multiple tokens  with the lowest time stamp, then the returned token will also  have the highest priority.
 */
public Token getNextToken(){
  if (_rcvrTimeTable.size() == 0) {
    return null;
  }
  RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.first();
  ODReceiver lowestRcvr=(ODReceiver)triple.getReceiver();
  _currentTime=triple.getTime();
  _lastPort=(ODIOPort)triple.getReceiver().getContainer();
  Token token=lowestRcvr.get();
  if (token != null) {
    System.out.println("String_Node_Str");
    return token;
  }
 else {
    if (this.hasMinRcvrTime()) {
      return getNextToken();
    }
 else {
      RcvrTimeTriple priorityTriple=getHighestPriorityTriple();
      lowestRcvr=(ODReceiver)priorityTriple.getReceiver();
      lowestRcvr.setSimultaneousIgnore(true);
      token=lowestRcvr.get();
      _lastPort=(ODIOPort)lowestRcvr.getContainer();
      if (token != null) {
        System.out.println("String_Node_Str");
        return token;
      }
 else {
        return getNextToken();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Get the next token which has the minimum rcvrTime and highest priority. The returned token will have the lowest time stamp of  all pending tokens for this actor. If there are multiple tokens  with the lowest time stamp, then the returned token will also  have the highest priority.
 */
public synchronized Token getNextToken(){
  ODDirector director=(ODDirector)getDirector();
  System.out.println("String_Node_Str");
  printRcvrTable();
  if (_rcvrTimeTable.size() == 0) {
    System.out.println("String_Node_Str");
    return null;
  }
  RcvrTimeTriple triple=(RcvrTimeTriple)_rcvrTimeTable.first();
  System.out.println("String_Node_Str");
  ODReceiver lowestRcvr=(ODReceiver)triple.getReceiver();
  _currentTime=triple.getTime();
  _lastPort=(ODIOPort)triple.getReceiver().getContainer();
  System.out.println("String_Node_Str" + _lastPort.getName());
  Token token=lowestRcvr.get();
  if (token != null) {
    System.out.println("String_Node_Str");
    return token;
  }
 else {
    if (this.hasMinRcvrTime()) {
      System.out.println("String_Node_Str");
      return getNextToken();
    }
 else {
      System.out.println("String_Node_Str");
      RcvrTimeTriple priorityTriple=getHighestPriorityTriple();
      lowestRcvr=(ODReceiver)priorityTriple.getReceiver();
      lowestRcvr.setSimultaneousIgnore(true);
      token=lowestRcvr.get();
      _lastPort=(ODIOPort)lowestRcvr.getContainer();
      if (token != null) {
        System.out.println("String_Node_Str");
        return token;
      }
 else {
        System.out.println("String_Node_Str");
        return getNextToken();
      }
    }
  }
}
Program: 76525
Project: 76525
Buggy source:
/** 
 * Remove the specified RcvrTimeTriple based on the _Receiver_. 
 */
private void _removeRcvrTable(RcvrTimeTriple triple){
  Receiver oldRcvr=triple.getReceiver();
  for (int cnt=0; cnt < _rcvrTimeTable.size(); cnt++) {
    RcvrTimeTriple newTriple=(RcvrTimeTriple)_rcvrTimeTable.at(cnt);
    Receiver rcvr=newTriple.getReceiver();
    if (rcvr == oldRcvr) {
      _rcvrTimeTable.removeAt(cnt);
      cnt=_rcvrTimeTable.size();
    }
  }
}

Fixed version (ground truth):
/** 
 * Remove the specified RcvrTimeTriple based on the _Receiver_. 
 */
private void _removeRcvrTable(RcvrTimeTriple triple){
  System.out.println("String_Node_Str");
  printRcvrTable();
  Receiver rcvrToBeRemoved=triple.getReceiver();
  for (int cnt=0; cnt < _rcvrTimeTable.size(); cnt++) {
    RcvrTimeTriple nextTriple=(RcvrTimeTriple)_rcvrTimeTable.at(cnt);
    Receiver nextRcvr=nextTriple.getReceiver();
    String portName1=nextRcvr.getContainer().getName();
    System.out.println(portName1 + "String_Node_Str");
    String portName2=rcvrToBeRemoved.getContainer().getName();
    System.out.println(portName2 + "String_Node_Str");
    if (rcvrToBeRemoved == nextRcvr) {
      String portName=nextRcvr.getContainer().getName();
      System.out.println(portName + "String_Node_Str" + cnt);
      _rcvrTimeTable.removeAt(cnt);
      cnt=_rcvrTimeTable.size();
    }
  }
  System.out.println("String_Node_Str");
  printRcvrTable();
}
Program: 76526
Project: 76526
Buggy source:
/** 
 * Increase the count of conditional branches that are blocked. Check if all the conditional branches are blocked, and if so register this actor as being blocked.
 */
protected void _branchBlocked(){
synchronized (_getInternalLock()) {
    _branchesBlocked++;
    if (_branchesBlocked == _branchesStarted) {
      ((CSPDirector)getDirector())._actorBlocked();
    }
  }
}

Fixed version (ground truth):
/** 
 * Increase the count of conditional branches that are blocked. Check if all the conditional branches are blocked, and if so register this actor as being blocked.
 */
protected void _branchBlocked(){
synchronized (_getInternalLock()) {
    _branchesBlocked++;
    if (_branchesBlocked == _branchesStarted) {
      ((CSPDirector)getDirector())._actorBlocked();
      _blocked=true;
    }
  }
}
Program: 76528
Project: 76528
Buggy source:
/** 
 * Decrease the count of conditional branches that are blocked. Check if all the conditional branches were previously blocked, and if so register this actor with the director as being unblocked.
 */
protected void _branchUnblocked(){
synchronized (_getInternalLock()) {
    if (_branchesBlocked == _branchesStarted) {
      ((CSPDirector)getDirector())._actorUnblocked();
    }
    _branchesBlocked--;
  }
}

Fixed version (ground truth):
/** 
 * Decrease the count of conditional branches that are blocked. Check if all the conditional branches were previously blocked, and if so register this actor with the director as being unblocked.
 */
protected void _branchUnblocked(){
synchronized (_getInternalLock()) {
    if (_branchesBlocked == _branchesStarted) {
      ((CSPDirector)getDirector())._actorUnblocked();
      _blocked=false;
    }
    _branchesBlocked--;
  }
}
Program: 76529
Project: 76529
Buggy source:
private void _resetConditionalState(){
synchronized (_getInternalLock()) {
    _branchesActive=0;
    _branchesBlocked=0;
    _branchesStarted=0;
    _branchTrying=-1;
    _successfulBranch=-1;
  }
}

Fixed version (ground truth):
private void _resetConditionalState(){
synchronized (_getInternalLock()) {
    _blocked=false;
    _branchesActive=0;
    _branchesBlocked=0;
    _branchesStarted=0;
    _branchTrying=-1;
    _successfulBranch=-1;
  }
}
Program: 76530
Project: 76530
Buggy source:
/** 
 * Clone this actor into the specified workspace. The new actor is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container.  A container must be set before much can be done with the actor.
 * @param ws The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return A new CSPActor.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  CSPActor newobj=(CSPActor)super.clone(ws);
  newobj._branchesActive=0;
  newobj._branchesBlocked=0;
  newobj._branchTrying=-1;
  newobj._delayed=false;
  newobj._internalLock=new Object();
  newobj._successfulBranch=-1;
  return newobj;
}

Fixed version (ground truth):
/** 
 * Clone this actor into the specified workspace. The new actor is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new actor with the same ports as the original, but no connections and no container.  A container must be set before much can be done with the actor.
 * @param ws The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return A new CSPActor.
 */
public Object clone(Workspace ws) throws CloneNotSupportedException {
  CSPActor newobj=(CSPActor)super.clone(ws);
  newobj._blocked=false;
  newobj._branchesActive=0;
  newobj._branchesBlocked=0;
  newobj._branchTrying=-1;
  newobj._delayed=false;
  newobj._internalLock=new Object();
  newobj._successfulBranch=-1;
  return newobj;
}
Program: 76531
Project: 76531
Buggy source:
/** 
 * Constructor.
 * @param container The container.
 * @param name The name of this actor.
 * @param value The initial output event value.
 * @param step The step size by which to increase the output event values.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Ramp(TypedCompositeActor container,String name,double value,double step) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  _value=new Parameter(this,"String_Node_Str",new DoubleToken(value));
  _step=new Parameter(this,"String_Node_Str",new DoubleToken(step));
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setMultiport(true);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setDeclaredType(Token.class);
}

Fixed version (ground truth):
/** 
 * Construct a Ramp with the specified container, name, initial value and step size. The initial value and step size are represented by String expressions which will be evaluated by the corresponding Parameters.
 * @param container The container.
 * @param name The name of this actor.
 * @param value The expression for the initial output event value.
 * @param step The expression for the step size by which toincrease the output event values.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Ramp(TypedCompositeActor container,String name,String value,String step) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  _value=new Parameter(this,"String_Node_Str");
  _value.setExpression(value);
  _step=new Parameter(this,"String_Node_Str");
  _step.setExpression(step);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setMultiport(true);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setDeclaredType(Token.class);
}
Program: 76532
Project: 76532
Buggy source:
/** 
 * Describe me
 */
public void initialize() throws IllegalActionException {
  Class valueClass=_value.getToken().getClass();
  Class stepClass=_value.getToken().getClass();
  int compare=TypeLattice.compare(valueClass,stepClass);
  if (compare == CPO.INCOMPARABLE) {
    throw new InvalidStateException("String_Node_Str");
  }
  if (compare == CPO.LOWER) {
    output.setDeclaredType(stepClass);
  }
 else {
    output.setDeclaredType(valueClass);
  }
  _stateToken=_value.getToken();
}

Fixed version (ground truth):
/** 
 * Describe me
 */
public void initialize() throws IllegalActionException {
  Class valueClass=_value.getToken().getClass();
  Class stepClass=_step.getToken().getClass();
  int compare=TypeLattice.compare(valueClass,stepClass);
  if (compare == CPO.INCOMPARABLE) {
    throw new InvalidStateException("String_Node_Str");
  }
  if (compare == CPO.LOWER) {
    output.setDeclaredType(stepClass);
  }
 else {
    output.setDeclaredType(valueClass);
  }
  _stateToken=_value.getToken();
}
Program: 76533
Project: 76533
Buggy source:
/** 
 * Check if write access in the workspace will be needed during an iteration. s     *  An iteration is defined to be one invocation of prefire(), fire(), and postfire() methods of the top level composite actor. <p> This method recursively call the needWriteAccess() method of all lower level directors. Intuitively, the workspace will only be made write- protected, if all the directors permit it.
 */
protected boolean _checkIfWriteAccessNeededDuringIteration(){
  CompositeActor toplevel=(CompositeActor)getToplevel();
  if (toplevel == null) {
    throw new InvalidStateException("String_Node_Str" + getName() + "String_Node_Str");
  }
  return toplevel.getDirector().needWriteAccess();
}

Fixed version (ground truth):
/** 
 * Check if write access in the workspace will be needed during an iteration. An iteration is defined to be one invocation of prefire(), fire(), and postfire() methods of the top level composite actor. <p> This method recursively call the needWriteAccess() method of all lower level directors. Intuitively, the workspace will only be made write- protected, if all the directors permit it.
 */
protected boolean _checkIfWriteAccessNeededDuringIteration(){
  CompositeActor toplevel=(CompositeActor)getToplevel();
  if (toplevel == null) {
    throw new InvalidStateException("String_Node_Str" + getName() + "String_Node_Str");
  }
  return toplevel.getDirector().needWriteAccess();
}
Program: 76536
Project: 76536
Buggy source:
/** 
 * Skip all data until we find the specified string. <p>This is especially useful for scanning comments. <p>This is a a little inefficient right now, since it calls tryRead() for every character.
 * @param delim The string delimiter
 * @see #tryRead(String,boolean)
 * @see #readCh
 */
void skipUntil(String delim) throws java.lang.Exception {
  while (!tryRead(delim)) {
    readCh();
  }
}

Fixed version (ground truth):
/** 
 * Skip all data until we find the specified string. <p>This is especially useful for scanning comments. <p>This is a a little inefficient right now, since it calls tryRead() for every character.
 * @param delim The string delimiter
 * @see #tryRead(String,boolean)
 * @see #readCh
 */
void skipUntil(String delim) throws java.lang.Exception {
  while (!tryRead(delim)) {
    char c;
    while (readBufferPos >= readBufferLength) {
switch (sourceType) {
case INPUT_READER:
case INPUT_EXTERNAL:
case INPUT_STREAM:
        readDataChunk();
      while (readBufferLength < 1) {
        popInput();
        if (readBufferLength < 1) {
          readDataChunk();
        }
      }
    break;
default :
  popInput();
break;
}
}
c=readBuffer[readBufferPos++];
if (c == '\n') {
line++;
column=0;
}
 else {
column++;
}
}
}
Program: 76537
Project: 76537
Buggy source:
/** 
 * This initializes the actor, and iterates it through the execution  cycle till it terminates.
 */
public void run(){
  try {
    boolean iterate=true;
    while (iterate) {
      if (((Entity)_actor).getContainer() != null && _actor.prefire()) {
        _actor.fire();
        iterate=_actor.postfire();
      }
      iterate=false;
    }
  }
 catch (  TerminateProcessException t) {
  }
catch (  IllegalActionException e) {
    _manager.fireExecutionError(e);
  }
 finally {
    try {
      _actor.wrapup();
    }
 catch (    IllegalActionException e) {
      _manager.fireExecutionError(e);
    }
    _director.decreaseActiveCount();
  }
}

Fixed version (ground truth):
/** 
 * This initializes the actor, and iterates it through the execution  cycle till it terminates.
 */
public void run(){
  try {
    boolean iterate=true;
    while (iterate) {
      iterate=false;
      if (((Entity)_actor).getContainer() != null && _actor.prefire()) {
        _actor.fire();
        iterate=_actor.postfire();
      }
    }
  }
 catch (  TerminateProcessException t) {
  }
catch (  IllegalActionException e) {
    _manager.fireExecutionError(e);
  }
 finally {
    try {
      _actor.wrapup();
    }
 catch (    IllegalActionException e) {
      _manager.fireExecutionError(e);
    }
    _director.decreaseActiveCount();
  }
}
Program: 76538
Project: 76538
Buggy source:
/** 
 * This initializes the actor, and iterates it through the execution  cycle till it terminates.
 */
public void run(){
  try {
    boolean iterate=true;
    while (iterate) {
      if (((Entity)_actor).getContainer() != null && _actor.prefire()) {
        _actor.fire();
        iterate=_actor.postfire();
      }
      iterate=false;
    }
  }
 catch (  TerminateProcessException t) {
  }
catch (  IllegalActionException e) {
    _manager.fireExecutionError(e);
  }
 finally {
    try {
      _actor.wrapup();
    }
 catch (    IllegalActionException e) {
      _manager.fireExecutionError(e);
    }
    _director.decreaseActiveCount();
  }
}

Fixed version (ground truth):
/** 
 * This initializes the actor, and iterates it through the execution  cycle till it terminates.
 */
public void run(){
  try {
    boolean iterate=true;
    while (iterate) {
      iterate=false;
      if (((Entity)_actor).getContainer() != null && _actor.prefire()) {
        _actor.fire();
        iterate=_actor.postfire();
      }
    }
  }
 catch (  TerminateProcessException t) {
  }
catch (  IllegalActionException e) {
    _manager.fireExecutionError(e);
  }
 finally {
    try {
      _actor.wrapup();
    }
 catch (    IllegalActionException e) {
      _manager.fireExecutionError(e);
    }
    _director.decreaseActiveCount();
  }
}
Program: 76539
Project: 76539
Buggy source:
/** 
 * If running and paused, resume the currently paused simulation by  turning off the paused flag and waking the simulation thread up. This thread is synchronized so that it runs atomically with respect to  the other methods in manager that control the simulation thread.
 */
public synchronized void resume(){
  if (_keepIterating && _isPaused) {
    _isPaused=false;
    if (_simulationThread != null)     _simulationThread.notify();
  }
}

Fixed version (ground truth):
/** 
 * If running and paused, resume the currently paused simulation by  turning off the paused flag and waking the simulation thread up. This thread is synchronized so that it runs atomically with respect to  the other methods in manager that control the simulation thread.
 */
public synchronized void resume(){
  if (_keepIterating && _isPaused) {
    _isPaused=false;
    if (_simulationThread != null) {
synchronized (_simulationThread) {
        _simulationThread.notify();
      }
    }
  }
}
Program: 76541
Project: 76541
Buggy source:
/** 
 * Set a flag to request that the thread in which execution is running  complete by calling wrapup() and then terminating.    This thread is synchronized so that it runs atomically with respect to  other methods in Manager that control the simulation thread. This method is non-blocking.   
 */
public synchronized void finish(){
  _keepIterating=false;
  _isPaused=false;
  if (_simulationThread != null)   _simulationThread.notify();
}

Fixed version (ground truth):
/** 
 * Set a flag to request that the thread in which execution is running  complete by calling wrapup() and then terminating.    This thread is synchronized so that it runs atomically with respect to  other methods in Manager that control the simulation thread. This method is non-blocking.   
 */
public synchronized void finish(){
  _keepIterating=false;
  _isPaused=false;
  if (_simulationThread != null) {
synchronized (_simulationThread) {
      _simulationThread.notify();
    }
  }
}
Program: 76542
Project: 76542
Buggy source:
/** 
 * Get the attribute with the given name. This method is read-synchronized on the workspace.
 * @param name The name of the desired attribute.
 * @return The requested attribute if it is found, null otherwise.
 */
public Attribute getAttribute(String name){
  try {
    workspace().getReadAccess();
    return (Attribute)_attributes.get(name);
  }
  finally {
    workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Get the attribute with the given name. This method is read-synchronized on the workspace.
 * @param name The name of the desired attribute.
 * @return The requested attribute if it is found, null otherwise.
 */
public Attribute getAttribute(String name){
  try {
    workspace().getReadAccess();
    if (_attributes == null) {
      return null;
    }
 else {
      return (Attribute)_attributes.get(name);
    }
  }
  finally {
    workspace().doneReading();
  }
}
Program: 76543
Project: 76543
Buggy source:
/** 
 * Construct a plot actor that uses the specified plot object. This can be used to create applets that plot the results of DE simulations.
 * @exception NameDuplicationException If the parent class throws it.
 * @exception IllegalActionException If the parent class throws it.
 */
public DELogicAnalyzer(TypedCompositeActor container,String name,LogicAnalyzer plot) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.makeMultiport(true);
  _logicAnalyzer=plot;
}

Fixed version (ground truth):
/** 
 * Construct a plot actor that uses the specified plot object. This can be used to create applets that plot the results of DE simulations.
 * @exception NameDuplicationException If the parent class throws it.
 * @exception IllegalActionException If the parent class throws it.
 */
public DELogicAnalyzer(TypedCompositeActor container,String name,LogicAnalyzer plot) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.makeMultiport(true);
  _logicAnalyzer=plot;
  _logicAnalyzer.setButtons(true);
}
Program: 76544
Project: 76544
Buggy source:
/** 
 * Add new input data to the plot.
 * @exception IllegalActionException Not thrown in this class.
 */
public void fire() throws IllegalActionException {
  if (!_rangeInitialized) {
    _plot.setXRange(getStartTime(),getStopTime());
    _plot.setYRange(getYMin(),getYMax());
    _plot.init();
    _plot.repaint();
    _rangeInitialized=true;
  }
  int numEmptyChannel=0;
  int width=input.getWidth();
  for (int i=0; i < width; i++) {
    if (input.hasToken(i)) {
      double curTime=((DECQDirector)getDirector()).getCurrentTime();
      while (input.hasToken(i)) {
        DoubleToken curToken=null;
        curToken=(DoubleToken)input.get(i);
        double curValue=curToken.doubleValue();
        boolean yRangeChanged=false;
        if (curValue < _yMin) {
          yRangeChanged=true;
          _yMin=curValue;
        }
        if (curValue > _yMax) {
          yRangeChanged=true;
          _yMax=curValue;
        }
        if (yRangeChanged) {
          _plot.setYRange(_yMin,_yMax);
          _plot.repaint();
        }
        _plot.addPoint(i,curTime,curValue,false);
      }
    }
 else {
      numEmptyChannel++;
    }
  }
  if (numEmptyChannel == width) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Add new input data to the plot.
 * @exception IllegalActionException Not thrown in this class.
 */
public void fire() throws IllegalActionException {
  if (!_rangeInitialized) {
    _plot.setXRange(getStartTime(),getStopTime());
    _plot.setYRange(getYMin(),getYMax());
    _plot.init();
    _plot.repaint();
    _rangeInitialized=true;
  }
  int numEmptyChannel=0;
  int width=input.getWidth();
  for (int i=0; i < width; i++) {
    if (input.hasToken(i)) {
      double curTime=((DECQDirector)getDirector()).getCurrentTime();
      while (input.hasToken(i)) {
        DoubleToken curToken=null;
        curToken=(DoubleToken)input.get(i);
        double curValue=curToken.doubleValue();
        boolean yRangeChanged=false;
        if (curValue < _yMin) {
          yRangeChanged=true;
          _yMin=curValue;
        }
        if (curValue > _yMax) {
          yRangeChanged=true;
          _yMax=curValue;
        }
        if (yRangeChanged) {
          _plot.setYRange(_yMin,_yMax);
          _plot.repaint();
        }
        if (DEBUG) {
          System.out.print(this.getFullName() + "String_Node_Str");
          System.out.println("String_Node_Str" + i + "String_Node_Str"+ curTime+ "String_Node_Str"+ curValue+ "String_Node_Str");
        }
        _plot.addPoint(i,curTime,curValue,false);
      }
    }
 else {
      numEmptyChannel++;
    }
  }
  if (numEmptyChannel == width) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
}
Program: 76545
Project: 76545
Buggy source:
/** 
 * Insert the given element, keeping the set sorted. If the set <i>contains</i> the given element, then do nothing.  If the type of given element is uncomparable by the comparator, then a ClassCastException  will be thrown.
 * @param obj The element to be inserted.
 */
public void insert(Object obj){
  int count=0;
  Enumeration elements=_set.elements();
  while (elements.hasMoreElements()) {
    Object next=elements.nextElement();
    int com=_comparator.compare(obj,next);
    if (com == 0) {
      break;
    }
    if (com < 0) {
      _set.insertAt(count,obj);
      break;
    }
    count++;
  }
}

Fixed version (ground truth):
/** 
 * Insert the given element, keeping the set sorted. If the set <i>contains</i> the given element, then do nothing.  If the type of given element is uncomparable by the comparator, then a ClassCastException  will be thrown.
 * @param obj The element to be inserted.
 */
public void insert(Object obj){
  int count=0;
  Enumeration elements=_set.elements();
  while (elements.hasMoreElements()) {
    Object next=elements.nextElement();
    int com=_comparator.compare(obj,next);
    if (com == 0) {
      return;
    }
    if (com < 0) {
      _set.insertAt(count,obj);
      return;
    }
    count++;
  }
  _set.insertLast(obj);
}
Program: 76546
Project: 76546
Buggy source:
/** 
 * Return the director. Note that the director returned is guaranteed to be non-null.
 * @return An instance of DEDirector.
 * @exception IllegalActionException If there is no container port, orif the port has no container actor, or if the actor has no director, or if the director is not an instance of DEDirector.
 */
public DEDirector getDirector() throws IllegalActionException {
  IOPort port=(IOPort)getContainer();
  if (port != null) {
    if (_directorVersion == port.workspace().getVersion()) {
      return _director;
    }
    Actor actor=(Actor)port.getContainer();
    if (actor != null) {
      Director dir=actor.getExecutiveDirector();
      if (dir != null) {
        if (dir instanceof DEDirector) {
          _director=(DEDirector)dir;
          _directorVersion=port.workspace().getVersion();
          return _director;
        }
      }
    }
  }
  throw new IllegalActionException(getContainer(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Return the director. Note that the director returned is guaranteed to be non-null.
 * @return An instance of DEDirector.
 * @exception IllegalActionException If there is no container port, orif the port has no container actor, or if the actor has no director, or if the director is not an instance of DEDirector.
 */
public DEDirector getDirector() throws IllegalActionException {
  IOPort port=(IOPort)getContainer();
  if (port != null) {
    if (_directorVersion == port.workspace().getVersion()) {
      return _director;
    }
    Actor actor=(Actor)port.getContainer();
    if (actor != null) {
      Director dir;
      if ((port.isOutput()) && (actor instanceof CompositeActor) && ((CompositeActor)actor).isOpaque()) {
        dir=actor.getDirector();
      }
 else {
        dir=actor.getExecutiveDirector();
      }
      if (dir != null) {
        if (dir instanceof DEDirector) {
          _director=(DEDirector)dir;
          _directorVersion=port.workspace().getVersion();
          return _director;
        }
      }
    }
  }
  throw new IllegalActionException(getContainer(),"String_Node_Str");
}
Program: 76547
Project: 76547
Buggy source:
/** 
 * Put a token with the specified delay into the receiver.  The time stamp of the token is equal to the current time (obtained from the director) plus the delay.  Note that this token does not become immediately available to the get() method. Instead, the token is queued with the director, and the director must put the token back into this receiver using the _triggerEvent() method in order for the token to become available.
 * @param token The token to put.
 * @param delay The delay of the token.
 * @exception IllegalActionException If the delay is negative, or ifthere is no director.
 */
public void put(Token token,double delay) throws NoRoomException, IllegalActionException {
  if (_isOCAOutput()) {
    _tokens.insertFirst(token);
    _tokendelays.insertFirst(new Double(delay));
  }
 else {
    getDirector().enqueueEvent(this,token,delay,_depth);
  }
}

Fixed version (ground truth):
/** 
 * Put a token with the specified delay into the receiver.  The time stamp of the token is equal to the current time (obtained from the director) plus the delay.  Note that this token does not become immediately available to the get() method. Instead, the token is queued with the director, and the director must put the token back into this receiver using the _triggerEvent() method in order for the token to become available.
 * @param token The token to put.
 * @param delay The delay of the token.
 * @exception IllegalActionException If the delay is negative, or ifthere is no director.
 */
public void put(Token token,double delay) throws NoRoomException, IllegalActionException {
  getDirector().enqueueEvent(this,token,delay,_depth);
}
Program: 76548
Project: 76548
Buggy source:
/** 
 * Find all the nodes that can be reached from the specified nodes. The reachable nodes do not include the specific ones unless there is a loop from the specified node back to itself. The implementation computes the transitive closure of the graph, if it is not already computed after the last graph change.  So the first call to this method after graph change may be slow, but all the subsequent calls return in constant time.
 * @param o an Object representing a node in this graph.
 * @return an array of Objects representing nodes reachable fromthe specified one.
 * @exception IllegalArgumentException If the specified Object isnot a node in this graph.
 */
public Object[] reachableNodes(Object[] objs){
  _computeTransitiveClosure();
  int N=objs.length;
  int ids[]=new int[N];
  for (int i=0; i < N; i++) {
    ids[i]=_getNodeId(objs[i]);
  }
  Vector nodes=new Vector(_transitiveClosure.length);
  for (int i=0; i < _transitiveClosure.length; i++) {
    boolean orthem=false;
    for (int j=0; j < N; j++) {
      orthem=orthem || _transitiveClosure[j][i];
    }
    if (orthem) {
      nodes.addElement(_getNodeObject(i));
    }
  }
  Object[] arr=new Object[nodes.size()];
  for (int i=0; i < nodes.size(); i++) {
    arr[i]=nodes.elementAt(i);
  }
  return arr;
}

Fixed version (ground truth):
/** 
 * Find all the nodes that can be reached from the specified nodes. The reachable nodes do not include the specific ones unless there is a loop from the specified node back to itself. The implementation computes the transitive closure of the graph, if it is not already computed after the last graph change.  So the first call to this method after graph change may be slow, but all the subsequent calls return in constant time.
 * @param o an Object representing a node in this graph.
 * @return an array of Objects representing nodes reachable fromthe specified one.
 * @exception IllegalArgumentException If the specified Object isnot a node in this graph.
 */
public Object[] reachableNodes(Object[] objs){
  _computeTransitiveClosure();
  int N=objs.length;
  int ids[]=new int[N];
  for (int i=0; i < N; i++) {
    ids[i]=_getNodeId(objs[i]);
  }
  Vector nodes=new Vector(_transitiveClosure.length);
  for (int i=0; i < _transitiveClosure.length; i++) {
    boolean orthem=false;
    for (int j=0; j < N; j++) {
      orthem=orthem || _transitiveClosure[ids[j]][i];
    }
    if (orthem) {
      nodes.addElement(_getNodeObject(i));
    }
  }
  Object[] arr=new Object[nodes.size()];
  for (int i=0; i < nodes.size(); i++) {
    arr[i]=nodes.elementAt(i);
  }
  return arr;
}
Program: 76549
Project: 76549
Buggy source:
/** 
 * Find all the nodes that can be reached backward from the specified nodes. The reachable nodes do not include the specific ones unless there is a loop from the specified node back to itself. The implementation computes the transitive closure of the graph, if it is not already computed after the last graph change.  So the first call to this method after graph change may be slow, but all the subsequent calls return in constant time.
 * @param o an Object representing a node in this graph.
 * @return an array of Objects representing nodes reachable fromthe specified one.
 * @exception IllegalArgumentException If the specified Object isnot a node in this graph.
 */
public Object[] backwardReachableNodes(Object[] objs){
  _computeTransitiveClosure();
  int N=objs.length;
  int ids[]=new int[N];
  for (int i=0; i < N; i++) {
    ids[i]=_getNodeId(objs[i]);
  }
  Vector nodes=new Vector(_transitiveClosure.length);
  for (int i=0; i < _transitiveClosure.length; i++) {
    boolean orthem=false;
    for (int j=0; j < N; j++) {
      orthem=orthem || _transitiveClosure[i][j];
    }
    if (orthem) {
      nodes.addElement(_getNodeObject(i));
    }
  }
  Object[] arr=new Object[nodes.size()];
  for (int i=0; i < nodes.size(); i++) {
    arr[i]=nodes.elementAt(i);
  }
  return arr;
}

Fixed version (ground truth):
/** 
 * Find all the nodes that can be reached backward from the specified nodes. The reachable nodes do not include the specific ones unless there is a loop from the specified node back to itself. The implementation computes the transitive closure of the graph, if it is not already computed after the last graph change.  So the first call to this method after graph change may be slow, but all the subsequent calls return in constant time.
 * @param o an Object representing a node in this graph.
 * @return an array of Objects representing nodes reachable fromthe specified one.
 * @exception IllegalArgumentException If the specified Object isnot a node in this graph.
 */
public Object[] backwardReachableNodes(Object[] objs){
  _computeTransitiveClosure();
  int N=objs.length;
  int ids[]=new int[N];
  for (int i=0; i < N; i++) {
    ids[i]=_getNodeId(objs[i]);
  }
  Vector nodes=new Vector(_transitiveClosure.length);
  for (int i=0; i < _transitiveClosure.length; i++) {
    boolean orthem=false;
    for (int j=0; j < N; j++) {
      orthem=orthem || _transitiveClosure[i][ids[j]];
    }
    if (orthem) {
      nodes.addElement(_getNodeObject(i));
    }
  }
  Object[] arr=new Object[nodes.size()];
  for (int i=0; i < nodes.size(); i++) {
    arr[i]=nodes.elementAt(i);
  }
  return arr;
}