nus-yam/ex-repair huggingface dataset:
Program: 76550
Project: 76550
Buggy source:
public void fire(){
  try {
    int count=0;
    int size=0;
    ConditionalBranch[] branches=new ConditionalBranch[2];
    while (true) {
      if (size < _depth) {
        branches[0]=new ConditionalReceive(input,0,0);
      }
      if (size > 0) {
        branches[1]=new ConditionalSend(output,1,1,_buffer[_readFrom]);
      }
      int successfulBranch=chooseBranch(branches);
      if (successfulBranch == 0) {
        size++;
        _buffer[_writeTo]=getToken();
        _writeTo++;
        System.out.println(getName() + "String_Node_Str" + getToken().toString()+ "String_Node_Str"+ _size);
      }
 else {
        _size--;
        _readFrom--;
        System.out.println(getName() + "String_Node_Str" + getToken().toString()+ "String_Node_Str"+ _size);
      }
      count++;
    }
  }
 catch (  IllegalActionException ex) {
    System.out.println("String_Node_Str");
  }
catch (  NoTokenException ex) {
    System.out.println("String_Node_Str");
  }
 finally {
    _again=false;
  }
}

Fixed version (ground truth):
public void fire(){
  try {
    int count=0;
    ConditionalBranch[] branches=new ConditionalBranch[2];
    while (true) {
      if (_size < _depth) {
        branches[0]=new ConditionalReceive(input,0,0);
      }
 else {
        branches[0]=null;
      }
      if (_size > 0) {
        branches[1]=new ConditionalSend(output,0,1,_buffer[_readFrom]);
      }
 else {
        branches[1]=null;
      }
      int successfulBranch=chooseBranch(branches);
      if (successfulBranch == 0) {
        _size++;
        _buffer[_writeTo]=getToken();
        _writeTo=++_writeTo % _depth;
        System.out.println(getName() + "String_Node_Str" + getToken().toString()+ "String_Node_Str"+ _size);
      }
 else {
        _size--;
        _readFrom=++_readFrom % _depth;
        System.out.println(getName() + "String_Node_Str" + getToken().toString()+ "String_Node_Str"+ _size);
      }
      count++;
    }
  }
 catch (  IllegalActionException ex) {
    System.out.println("String_Node_Str" + ex.getMessage());
  }
catch (  NoTokenException ex) {
    System.out.println("String_Node_Str");
  }
 finally {
    _again=false;
  }
}
Program: 76551
Project: 76551
Buggy source:
/** 
 * Return the Complex value contained by this token.
 * @return The Compelx value contained by this token.
 */
public Complex getValue(){
  return _value;
}

Fixed version (ground truth):
/** 
 * Return the Complex value contained by this token.
 * @return The Compelx value contained by this token.
 */
public Complex getValue(){
  return complexValue();
}
Program: 76552
Project: 76552
Buggy source:
/** 
 * Called to report an execution failure
 */
public void executionError(ExecutionEvent event){
  Debug.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Called to report an execution failure
 */
public void executionError(ExecutionEvent event){
  Debug.println("String_Node_Str");
  Exception e=event.getException();
  e.printStackTrace();
}
Program: 76553
Project: 76553
Buggy source:
/** 
 * Erase the point at the given index in the given dataset.  If lines are being drawn, also erase the line to the next points (note: not to the previous point).  The point is not checked to see whether it is in range, so care must be taken by the caller to ensure that it is. The change will be made visible if the plot is visible on the screen.  Otherwise, it will take effect the next time the plot is drawn on the screen.
 * @param dataset The data set index.
 * @param index The index of the point to erase.
 */
public synchronized void erasePoint(int dataset,int index){
  if (isShowing()) {
    _erasePoint(getGraphics(),dataset,index);
  }
  Vector points=(Vector)_points.elementAt(dataset);
  if (points != null) {
    PlotPoint pt=(PlotPoint)points.elementAt(index);
    if (pt != null) {
      if (pt.x == _xBottom || pt.x == _xTop || pt.y == _yBottom || pt.y == _yTop) {
        _xyInvalid=true;
      }
      points.removeElementAt(index);
    }
  }
}

Fixed version (ground truth):
/** 
 * Erase the point at the given index in the given dataset.  If lines are being drawn, also erase the line to the next points (note: not to the previous point).  The point is not checked to see whether it is in range, so care must be taken by the caller to ensure that it is. The change will be made visible if the plot is visible on the screen.  Otherwise, it will take effect the next time the plot is drawn on the screen.
 * @param dataset The data set index.
 * @param index The index of the point to erase.
 */
public synchronized void erasePoint(int dataset,int index){
  _checkDatasetIndex(dataset);
  if (isShowing()) {
    _erasePoint(getGraphics(),dataset,index);
  }
  Vector points=(Vector)_points.elementAt(dataset);
  if (points != null) {
    PlotPoint pt=(PlotPoint)points.elementAt(index);
    if (pt != null) {
      if (pt.x == _xBottom || pt.x == _xTop || pt.y == _yBottom || pt.y == _yTop) {
        _xyInvalid=true;
      }
      points.removeElementAt(index);
    }
  }
}
Program: 76554
Project: 76554
Buggy source:
/** 
 * Add a port to this actor. This overrides the base class to throw an exception if the added port is not an instance of IOPort.  This method should not be used directly.  Call the setContainer() method of the port instead. This method does not set the container of the port to point to this actor. It assumes that the port is in the same workspace as this actor, but does not check.  The caller should check. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @param port The port to add to this actor.
 * @exception IllegalActionException If the port class is notacceptable to this actor, or the port has no name.
 * @exception NameDuplicationException If the port name collides with aname already in the actor.
 */
protected void _addPort(Port port) throws IllegalActionException, NameDuplicationException {
  if (!(port instanceof ComponentPort)) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  super._addPort(port);
}

Fixed version (ground truth):
/** 
 * Add a port to this actor. This overrides the base class to throw an exception if the added port is not an instance of IOPort.  This method should not be used directly.  Call the setContainer() method of the port instead. This method does not set the container of the port to point to this actor. It assumes that the port is in the same workspace as this actor, but does not check.  The caller should check. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @param port The port to add to this actor.
 * @exception IllegalActionException If the port class is notacceptable to this actor, or the port has no name.
 * @exception NameDuplicationException If the port name collides with aname already in the actor.
 */
protected void _addPort(Port port) throws IllegalActionException, NameDuplicationException {
  if (!(port instanceof IOPort)) {
    throw new IllegalActionException(this,port,"String_Node_Str");
  }
  super._addPort(port);
}
Program: 76555
Project: 76555
Buggy source:
/** 
 * Rescale so that the data that is currently plotted just fits. This overrides the base class method to ensure that the protected variables _xBottom, _xTop, _yBottom, and _yTop are valid. This method calls repaint(), which eventually causes the display to be updated.
 */
public synchronized void fillPlot(){
  if (_xyInvalid) {
    _xBottom=Double.MAX_VALUE;
    _xTop=-Double.MIN_VALUE;
    _yBottom=Double.MAX_VALUE;
    _yTop=-Double.MIN_VALUE;
    for (int dataset=0; dataset < _points.size(); dataset++) {
      Vector points=(Vector)_points.elementAt(dataset);
      for (int index=0; index < points.size(); index++) {
        PlotPoint pt=(PlotPoint)points.elementAt(index);
        if (pt.x < _xBottom)         _xBottom=pt.x;
        if (pt.x > _xTop)         _xTop=pt.x;
        if (pt.y < _yBottom)         _yBottom=pt.y;
        if (pt.y > _yTop)         _yTop=pt.y;
      }
    }
  }
  _xyInvalid=false;
  super.fillPlot();
}

Fixed version (ground truth):
/** 
 * Rescale so that the data that is currently plotted just fits. This overrides the base class method to ensure that the protected variables _xBottom, _xTop, _yBottom, and _yTop are valid. This method calls repaint(), which eventually causes the display to be updated.
 */
public synchronized void fillPlot(){
  if (_xyInvalid) {
    _xBottom=Double.MAX_VALUE;
    _xTop=-Double.MIN_VALUE;
    _yBottom=Double.MAX_VALUE;
    _yTop=-Double.MIN_VALUE;
    for (int dataset=0; dataset < _points.size(); dataset++) {
      Vector points=(Vector)_points.elementAt(dataset);
      for (int index=0; index < points.size(); index++) {
        PlotPoint pt=(PlotPoint)points.elementAt(index);
        if (pt.x < _xBottom)         _xBottom=pt.x;
        if (pt.x > _xTop)         _xTop=pt.x;
        if (pt.y < _yBottom)         _yBottom=pt.y;
        if (pt.y > _yTop)         _yTop=pt.y;
      }
    }
  }
  _xyInvalid=false;
  if (_bars) {
    if (_yBottom > 0.0)     _yBottom=0.0;
    if (_yTop < 0.0)     _yTop=0.0;
  }
  super.fillPlot();
}
Program: 76557
Project: 76557
Buggy source:
/** 
 * If paused, resume the currently paused simulation.
 */
public synchronized void resume(){
  _isPaused=false;
  _runningthread.notify();
}

Fixed version (ground truth):
/** 
 * If paused, resume the currently paused simulation.
 */
public synchronized void resume(){
  if (_isRunning && _isPaused) {
    _isPaused=false;
    if (_runningthread != null)     _runningthread.notify();
  }
}
Program: 76558
Project: 76558
Buggy source:
/** 
 * Stop any currently executing simulation and cleanup nicely.
 */
public synchronized void wrapup(){
  _isRunning=false;
  _isPaused=false;
  _runningthread.notify();
}

Fixed version (ground truth):
/** 
 * Stop any currently executing simulation and cleanup nicely.
 */
public synchronized void wrapup(){
  _isRunning=false;
  _isPaused=false;
  if (_runningthread != null)   _runningthread.notify();
}
Program: 76559
Project: 76559
Buggy source:
/** 
 * Start an execution that will run for no more than a specified number of iterations.   The execution may be terminated early  by calling abort, finish, or returning false in a postfire method.
 */
public synchronized void go(int iterations){
  if (_isRunning)   return;
  _isRunning=true;
  _isPaused=false;
  _iterations=iterations;
  if (_runningthread != null) {
    _runningthread.stop();
    try {
      _runningthread.join();
    }
 catch (    InterruptedException e) {
    }
    _runningthread=null;
  }
  _runningthread=new Thread(this);
  _runningthread.start();
}

Fixed version (ground truth):
/** 
 * Start an execution that will run for no more than a specified number of iterations.   The execution may be terminated early  by calling abort, finish, or returning false in a postfire method. This method starts a new ManagerExecutionThread which will call back to this object in 'blockingGo'.
 */
public synchronized void go(int iterations){
  if (_isRunning)   return;
  _iterations=iterations;
  if (_runningthread != null) {
    _runningthread.stop();
    try {
      _runningthread.join();
    }
 catch (    InterruptedException e) {
    }
    _runningthread=null;
  }
  _runningthread=new ManagerExecutionThread(this,iterations);
  _runningthread.start();
}
Program: 76560
Project: 76560
Buggy source:
/** 
 * Terminate any currently executing simulation with extreme prejudice.   Kill the main execution thread and call terminate on the toplevel  container.   This should cause any actors to free up any resources  they have allocated and directors should kill any threads they have  created.   However, a consistant state is not guaraunteed.   The  environment should probably be restarted before attemping any further operations.
 */
public void terminate(){
  _runningthread.stop();
  try {
    _runningthread.join();
  }
 catch (  InterruptedException e) {
  }
  _runningthread=null;
  CompositeActor container=((CompositeActor)getContainer());
  container.terminate();
  ExecutionEvent event=new ExecutionEvent(this);
  Enumeration listeners=_ExecutionListeners.elements();
  while (listeners.hasMoreElements()) {
    ExecutionListener l=(ExecutionListener)listeners.nextElement();
    l.executionTerminated(event);
  }
}

Fixed version (ground truth):
/** 
 * Terminate any currently executing simulation with extreme prejudice.   Kill the main execution thread and call terminate on the toplevel  container.   This should cause any actors to free up any resources  they have allocated and directors should kill any threads they have  created.   However, a consistant state is not guaraunteed.   The  environment should probably be restarted before attemping any further operations.
 */
public void terminate(){
  if (_runningthread != null) {
    _runningthread.stop();
    try {
      _runningthread.join();
    }
 catch (    InterruptedException e) {
    }
    _runningthread=null;
  }
  CompositeActor container=((CompositeActor)getContainer());
  container.terminate();
  ExecutionEvent event=new ExecutionEvent(this);
  Enumeration listeners=_ExecutionListeners.elements();
  while (listeners.hasMoreElements()) {
    ExecutionListener l=(ExecutionListener)listeners.nextElement();
    l.executionTerminated(event);
  }
  _isRunning=false;
  _isPaused=false;
}
Program: 76561
Project: 76561
Buggy source:
/** 
 * If not paused, then pause the simulation.
 */
public synchronized void pause(){
  _isPaused=true;
}

Fixed version (ground truth):
/** 
 * If not paused, then pause the simulation.
 */
public synchronized void pause(){
  if (_isRunning)   _isPaused=true;
}
Program: 76562
Project: 76562
Buggy source:
/** 
 * Get the ID of this event. The ID may give some additional  information about why the Parameter changed.
 * @return The integer ID.
 */
public int getID(){
  return _id;
}

Fixed version (ground truth):
/** 
 * Get the ID of this event. The ID may give some additional  information about why the Parameter changed.
 * @return The integer ID.
 */
public int getID(){
  return id;
}
Program: 76563
Project: 76563
Buggy source:
/** 
 * Get the Parameter associated with this event. 
 * @return The Parameter which changed or was removed.
 */
public int getParameter(){
  return _parameter;
}

Fixed version (ground truth):
/** 
 * Get the Parameter associated with this event. 
 * @return The Parameter which changed or was removed.
 */
public Parameter getParameter(){
  return _parameter;
}
Program: 76564
Project: 76564
Buggy source:
/** 
 * This is the thread that is started to actually perform the execution. It begins by calling initialize on its container, which is the toplevel composite actor.   It then continually calls iterate based on the variables _isRunning, _isPaused, and _iterations.  It finally  calls wrapup on its container to clean up after the execution.
 */
public void run(){
  CompositeActor container=((CompositeActor)getContainer());
  int count=0;
  int iterations;
  try {
    try {
      iterations=_iterations;
      container.initialize();
      while (_isRunning && ((iterations < 0) || (count++ < iterations)) && iterate()) {
        try {
          if (_isPaused)           _runningthread.wait();
        }
 catch (        InterruptedException e) {
        }
      }
    }
  finally {
      container.wrapup();
    }
  }
 catch (  IllegalActionException e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * This is the thread that is started to actually perform the execution. It begins by calling initialize on its container, which is the toplevel composite actor.   It then continually calls iterate based on the variables _isRunning, _isPaused, and _iterations.  It finally  calls wrapup on its container to clean up after the execution.
 */
public void run(){
  CompositeActor container=((CompositeActor)getContainer());
  int count=0;
  int iterations;
  try {
    try {
      iterations=_iterations;
      container.initialize();
      while (_isRunning && ((iterations < 0) || (count++ < iterations)) && iterate()) {
        try {
          if (_isPaused)           _runningthread.wait();
        }
 catch (        InterruptedException e) {
        }
      }
    }
  finally {
      _isRunning=false;
      _isPaused=false;
      container.wrapup();
    }
  }
 catch (  IllegalActionException e) {
    System.out.println("String_Node_Str");
    e.printStackTrace();
  }
}
Program: 76565
Project: 76565
Buggy source:
/** 
 * If this port is transparent, then deeply enumerate the ports connected on the inside.  Otherwise, enumerate just this port. All ports enumerated are opaque. Note that the returned enumeration could conceivably be empty, for example if this port is transparent but has no inside links. Also, a port may be listed more than once if more than one inside connection to it has been established. This method is read-synchronized on the workspace.
 * @return An enumeration of ComponentPort objects.
 */
public Enumeration deepInsidePorts(){
  try {
    workspace().getReadAccess();
    if (_deeplinkedinportsversion == workspace().getVersion()) {
      return _deeplinkedinports.elements();
    }
    LinkedList result=new LinkedList();
    if (isOpaque()) {
      result.insertLast(this);
    }
 else {
      Enumeration relations=insideRelations();
      while (relations.hasMoreElements()) {
        Relation relation=(Relation)relations.nextElement();
        Enumeration insideports=relation.linkedPorts(this);
        while (insideports.hasMoreElements()) {
          ComponentPort downport=(ComponentPort)insideports.nextElement();
          if (downport._outside(relation.getContainer())) {
            if (downport.isOpaque()) {
              result.insertLast(downport);
            }
 else {
              result.appendElements(downport.deepConnectedPorts());
            }
          }
 else {
            result.appendElements(downport.deepInsidePorts());
          }
        }
      }
    }
    _deeplinkedinports=result;
    _deeplinkedinportsversion=workspace().getVersion();
    return _deeplinkedinports.elements();
  }
  finally {
    workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * If this port is transparent, then deeply enumerate the ports connected on the inside.  Otherwise, enumerate just this port. All ports enumerated are opaque. Note that the returned enumeration could conceivably be empty, for example if this port is transparent but has no inside links. Also, a port may be listed more than once if more than one inside connection to it has been established.
 * @return An enumeration of ComponentPort objects.
 */
public Enumeration deepInsidePorts(){
  try {
    workspace().getReadAccess();
    return _deepInsidePorts(null);
  }
  finally {
    workspace().doneReading();
  }
}
Program: 76566
Project: 76566
Buggy source:
/** 
 * Deeply enumerate the ports connected to this port on the outside. Begin by enumerating the ports that are connected to this port. If any of those are transparent ports that we are connected to from the inside, then enumerate all the ports deeply connected on the outside to that transparent port.  Note that a port may be listed more than once. This method is read-synchronized on the workspace.
 * @return An enumeration of ComponentPort objects.
 */
public Enumeration deepConnectedPorts(){
  try {
    workspace().getReadAccess();
    if (_deeplinkedportsversion == workspace().getVersion()) {
      return _deeplinkedports.elements();
    }
    Enumeration nearrelations=linkedRelations();
    LinkedList result=new LinkedList();
    while (nearrelations.hasMoreElements()) {
      ComponentRelation relation=(ComponentRelation)nearrelations.nextElement();
      Enumeration connectedports=relation.linkedPorts(this);
      while (connectedports.hasMoreElements()) {
        ComponentPort port=(ComponentPort)connectedports.nextElement();
        if (port._outside(relation.getContainer())) {
          if (port.isOpaque()) {
            result.insertLast(port);
          }
 else {
            result.appendElements(port.deepConnectedPorts());
          }
        }
 else {
          if (port.isOpaque()) {
            result.insertLast(port);
          }
 else {
            result.appendElements(port.deepInsidePorts());
          }
        }
      }
    }
    _deeplinkedports=result;
    _deeplinkedportsversion=workspace().getVersion();
    return _deeplinkedports.elements();
  }
  finally {
    workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Deeply enumerate the ports connected to this port on the outside. Begin by enumerating the ports that are connected to this port. If any of those are transparent ports that we are connected to from the inside, then enumerate all the ports deeply connected on the outside to that transparent port.  Note that a port may be listed more than once. This method read synchronized on the workspace.
 * @return An enumeration of ComponentPort objects.
 */
public Enumeration deepConnectedPorts(){
  try {
    workspace().getReadAccess();
    return _deepConnectedPorts(null);
  }
  finally {
    workspace().doneReading();
  }
}
Program: 76567
Project: 76567
Buggy source:
/** 
 * Produce an output event at the current time, and then schedule a firing in the future.
 * @exception CloneNotSupportedException If there is more than onedestination and the output token cannot be cloned.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  output.broadcast(_value.getToken());
  refireAtTime(((DoubleToken)_interval.getToken()).doubleValue());
}

Fixed version (ground truth):
/** 
 * Produce an output event at the current time, and then schedule a firing in the future.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  output.broadcast(_value.getToken());
  refireAtTime(((DoubleToken)_interval.getToken()).doubleValue());
}
Program: 76568
Project: 76568
Buggy source:
/** 
 * Produce the initializer event that will cause the generation of the first output at time zero. FIXME: What to do if the initial current event is less than zero ?
 * @exception CloneNotSupportedException If the base class throws it.
 * @exception IllegalActionException If there is no director.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  double curTime=getCurrentTime();
  refireAtTime(0.0 - curTime);
}

Fixed version (ground truth):
/** 
 * Produce the initializer event that will cause the generation of the first output at time zero. FIXME: What to do if the initial current event is less than zero ?
 * @exception IllegalActionException If there is no director.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  double curTime=getCurrentTime();
  refireAtTime(0.0 - curTime);
}
Program: 76569
Project: 76569
Buggy source:
/** 
 * Transfer the input tokens to the outputs with the specified delay.
 * @exception CloneNotSupportedException If the output has multipledestinations and the token does not support cloning.
 * @exception IllegalActionException Not thrown in this class.
 */
public void fire() throws IllegalActionException {
  for (int i=0; i < input.getWidth(); i++) {
    Token inputToken;
    inputToken=input.get(i);
    output.send(i,inputToken,((DoubleToken)_delay.getToken()).doubleValue());
  }
}

Fixed version (ground truth):
/** 
 * Transfer the input tokens to the outputs with the specified delay.
 * @exception IllegalActionException Not thrown in this class.
 */
public void fire() throws IllegalActionException {
  for (int i=0; i < input.getWidth(); i++) {
    Token inputToken;
    inputToken=input.get(i);
    output.send(i,inputToken,((DoubleToken)_delay.getToken()).doubleValue());
  }
}
Program: 76570
Project: 76570
Buggy source:
/** 
 * Rescale the plot so that all the data plotted is visible.
 */
public void wrapup() throws IllegalActionException {
  double binWidth=((DoubleToken)_binWidth.getToken()).doubleValue();
  for (int i=0; i < _dataCount.capacity(); i++) {
    Object d=_dataCount.elementAt(i);
    if (d != null) {
      Integer y=(Integer)d;
      _plot.addPoint(0,i * binWidth + .5 * binWidth,y.doubleValue(),false);
    }
  }
  _plot.fillPlot();
  super.wrapup();
}

Fixed version (ground truth):
/** 
 * Rescale the plot so that all the data plotted is visible.
 * @exception IllegalActionException If the parent class throws it.
 */
public void wrapup() throws IllegalActionException {
  double binWidth=((DoubleToken)_binWidth.getToken()).doubleValue();
  Enumeration keys=_map.keys();
  while (keys.hasMoreElements()) {
    Integer bin=(Integer)keys.nextElement();
    Integer height=(Integer)_map.at(bin);
    double binCenter=bin.intValue() * binWidth + _binZeroOffset;
    _plot.addPoint(0,binCenter,height.intValue(),false);
  }
  _plot.fillPlot();
  super.wrapup();
}
Program: 76571
Project: 76571
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.
 */
public DEHistogram(CompositeActor container,String name,double binWidth,Plot plot) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new IOPort(this,"String_Node_Str",true,false);
  input.makeMultiport(true);
  _plot=plot;
  _plot.setBars(0.95 * binWidth,0.05 * binWidth);
  _yMin=(double)-1;
  _yMax=(double)1;
  _binWidth=new Parameter(this,"String_Node_Str",new DoubleToken(binWidth));
}

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 DEHistogram(CompositeActor container,String name,double binWidth,Plot plot) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new IOPort(this,"String_Node_Str",true,false);
  input.makeMultiport(true);
  _plot=plot;
  _plot.setBars((1 - _percentGap) * binWidth,0.25 * _percentGap * binWidth);
  _yMin=(double)-1;
  _yMax=(double)1;
  _binWidth=new Parameter(this,"String_Node_Str",new DoubleToken(binWidth));
  _binZeroOffset=binWidth / 2.0;
}
Program: 76572
Project: 76572
Buggy source:
/** 
 * Add new input data to the plot.
 */
public void fire() throws IllegalActionException {
  while (input.hasToken(0)) {
    double dataIn=((DoubleToken)input.get(0)).doubleValue();
    double width=((DoubleToken)_binWidth.getToken()).doubleValue();
    int binNum=(int)(dataIn / width);
    if (_dataCount.size() < binNum + 1) {
      _dataCount.setSize(binNum + 1);
    }
    Object d=_dataCount.elementAt(binNum);
    if (d == null) {
      _dataCount.setElementAt(new Integer(1),binNum);
    }
 else {
      Integer dd=(Integer)d;
      _dataCount.setElementAt(new Integer(dd.intValue() + 1),binNum);
    }
  }
}

Fixed version (ground truth):
/** 
 * Add new input data to the plot.
 * @exception IllegalActionException If the input port is disconnected.
 */
public void fire() throws IllegalActionException {
  while (input.hasToken(0)) {
    double dataIn=((DoubleToken)input.get(0)).doubleValue();
    int bin=_valueToBin(dataIn);
    if (bin > _maxBin)     _maxBin=bin;
    if (bin < _minBin)     _minBin=bin;
    Integer binObject=new Integer(bin);
    if (_map.includesKey(binObject)) {
      int oldVal=((Integer)_map.at(binObject)).intValue();
      _map.putAt(binObject,new Integer(oldVal + 1));
    }
 else {
      _map.putAt(binObject,new Integer(1));
    }
  }
}
Program: 76573
Project: 76573
Buggy source:
/** 
 * Clear the plot window.
 */
public void initialize() throws IllegalActionException {
  _plot.clear(false);
  _dataCount=new Vector();
}

Fixed version (ground truth):
/** 
 * Initialize the plot window by clearing it, and also clear the map collection.
 * @exception IllegalActionException Not thrown in this class.
 */
public void initialize() throws IllegalActionException {
  _plot.clear(false);
  _map.clear();
  _maxBin=Integer.MIN_VALUE;
  _minBin=Integer.MAX_VALUE;
}
Program: 76574
Project: 76574
Buggy source:
/** 
 * If there's an event in the "input" port, pass it depending on the "gate" input; if there's no event in the input port, but only in the "gate" input, pass event when the gate reopens.
 * @exception CloneNotSupportedException Error when cloning event.
 * @exception IllegalActionException Not thrown in this class.
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    DoubleToken inputToken=null;
    inputToken=(DoubleToken)(input.get(0));
    if (gate.hasToken(0)) {
      DoubleToken gateToken=null;
      gateToken=(DoubleToken)(gate.get(0));
      if (gateToken.getValue() == 0.0) {
        _gateOpen=false;
      }
 else {
        _gateOpen=true;
      }
    }
    if (_gateOpen) {
      output.broadcast(inputToken);
      return;
    }
 else {
      _lastToken=inputToken;
    }
  }
 else   if (gate.hasToken(0)) {
    DoubleToken gateToken=null;
    gateToken=(DoubleToken)(gate.get(0));
    if (gateToken.getValue() != 0.0 && _gateOpen == false) {
      _gateOpen=true;
      output.broadcast(_lastToken);
      return;
    }
 else     if (gateToken.getValue() == 0 && _gateOpen == true) {
      _gateOpen=false;
      return;
    }
  }
 else {
    throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * If there's an event in the "input" port, pass it depending on the "gate" input; if there's no event in the input port, but only in the "gate" input, pass event when the gate reopens.
 * @exception IllegalActionException Not thrown in this class.
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    DoubleToken inputToken=null;
    inputToken=(DoubleToken)(input.get(0));
    if (gate.hasToken(0)) {
      DoubleToken gateToken=null;
      gateToken=(DoubleToken)(gate.get(0));
      if (gateToken.getValue() == 0.0) {
        _gateOpen=false;
      }
 else {
        _gateOpen=true;
      }
    }
    if (_gateOpen) {
      output.broadcast(inputToken);
      return;
    }
 else {
      _lastToken=inputToken;
    }
  }
 else   if (gate.hasToken(0)) {
    DoubleToken gateToken=null;
    gateToken=(DoubleToken)(gate.get(0));
    if (gateToken.getValue() != 0.0 && _gateOpen == false) {
      _gateOpen=true;
      output.broadcast(_lastToken);
      return;
    }
 else     if (gateToken.getValue() == 0 && _gateOpen == true) {
      _gateOpen=false;
      return;
    }
  }
 else {
    throw new InvalidStateException("String_Node_Str" + "String_Node_Str");
  }
}
Program: 76575
Project: 76575
Buggy source:
/** 
 * @exception CloneNotSupportedException Not thrown in this base class.
 * @exception IllegalActionException Thrown if could not create the receivers.
 */
public void initialize() throws IllegalActionException {
  _gateOpen=true;
  _lastToken=null;
}

Fixed version (ground truth):
/** 
 * Initialize gate to be open, and last token equal null.
 * @exception IllegalActionException Thrown if could not create the receivers.
 */
public void initialize() throws IllegalActionException {
  _gateOpen=true;
  _lastToken=null;
}
Program: 76576
Project: 76576
Buggy source:
/** 
 * Rescale the plot so that all the data plotted is visible.
 */
public void wrapup() throws IllegalActionException {
  _plot.fillPlot();
  super.wrapup();
}

Fixed version (ground truth):
/** 
 * Rescale the plot so that all the data plotted is visible.
 * @exception IllegalActionException If the parent class throws it.
 */
public void wrapup() throws IllegalActionException {
  _plot.fillPlot();
  super.wrapup();
}
Program: 76577
Project: 76577
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.
 */
public DEPlot(CompositeActor container,String name,Plot plot) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new IOPort(this,"String_Node_Str",true,false);
  input.makeMultiport(true);
  _plot=plot;
  _plot.setMarksStyle("String_Node_Str");
  _plot.setImpulses(true);
  _plot.setConnected(false);
  _yMin=(double)-1;
  _yMax=(double)1;
}

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 DEPlot(CompositeActor container,String name,Plot plot) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  input=new IOPort(this,"String_Node_Str",true,false);
  input.makeMultiport(true);
  _plot=plot;
  _plot.setMarksStyle("String_Node_Str");
  _plot.setImpulses(true);
  _plot.setConnected(false);
  _yMin=(double)-1;
  _yMax=(double)1;
}
Program: 76578
Project: 76578
Buggy source:
/** 
 * Add new input data to the plot.
 */
public void fire() throws IllegalActionException {
  if (_firstFiring) {
    _plot.setXRange(getStartTime(),getStopTime());
    _plot.setYRange(getYMin(),getYMax());
    _firstFiring=false;
  }
  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();
        _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 {
  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();
        _plot.addPoint(i,curTime,curValue,false);
      }
    }
 else {
      numEmptyChannel++;
    }
  }
  if (numEmptyChannel == width) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
}
Program: 76579
Project: 76579
Buggy source:
/** 
 * Clear the plot window.
 */
public void initialize() throws IllegalActionException {
  _plot.clear(false);
}

Fixed version (ground truth):
/** 
 * Clear the plot window.
 * @exception IllegalActionException Not thrown in this class.
 */
public void initialize() throws IllegalActionException {
  _plot.clear(false);
  _plot.setXRange(getStartTime(),getStopTime());
  _plot.setYRange(getYMin(),getYMax());
  _plot.init();
}
Program: 76580
Project: 76580
Buggy source:
/** 
 * Return a token on the queue.  If the offset argument is zero, return the most recent token that was put on the queue. If the offset is 1, return the second most recent token, etc. Do not remove the token from the queue. If there is no such token on the queue (the offset is greater than or equal to the size, or is negative), throw an exception.
 * @param offset The offset from the most recent item on the queue.
 * @exception NoSuchItemException The offset is out of range.
 */
public Token get(int offset){
  try {
    return (Token)_queue.get(offset);
  }
 catch (  NoSuchElementException ex) {
    throw new NoTokenException(getContainer(),"String_Node_Str" + offset + "String_Node_Str"+ _queue.size());
  }
}

Fixed version (ground truth):
/** 
 * Return a token on the queue.  If the offset argument is zero, return the most recent token that was put on the queue. If the offset is 1, return the second most recent token, etc. Do not remove the token from the queue. If there is no such token on the queue (the offset is greater than or equal to the size, or is negative), throw an exception.
 * @param offset The offset from the most recent item on the queue.
 * @exception NoTokenException The offset is out of range.
 */
public Token get(int offset){
  try {
    return (Token)_queue.get(offset);
  }
 catch (  NoSuchElementException ex) {
    throw new NoTokenException(getContainer(),"String_Node_Str" + offset + "String_Node_Str"+ _queue.size());
  }
}
Program: 76581
Project: 76581
Buggy source:
/** 
 * Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param rightArg The token to subtract to this Token.
 * @exception IllegalActionException If the passed token isnot of a type that can be subtracted from this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtract(Token rightArg) throws IllegalActionException {
  int typeInfo=TypeCPO.compare(this,rightArg);
  try {
    if (typeInfo == CPO.LOWER) {
      return rightArg.addR(this);
    }
 else     if (rightArg instanceof DoubleToken) {
      double result=_value - ((DoubleToken)rightArg).getValue();
      return new DoubleToken(result);
    }
 else     if (typeInfo == CPO.HIGHER) {
      DoubleToken tmp=(DoubleToken)this.convert(rightArg);
      double result=_value - tmp.getValue();
      return new DoubleToken(result);
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception ex) {
    String str="String_Node_Str";
    str=str + this.getClass().getName() + "String_Node_Str";
    str=str + rightArg.getClass().getName();
    throw new IllegalActionException(str + "String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param rightArg The token to subtract to this Token.
 * @exception IllegalActionException If the passed token isnot of a type that can be subtracted from this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtract(Token rightArg) throws IllegalActionException {
  int typeInfo=TypeCPO.compare(this,rightArg);
  try {
    if (typeInfo == CPO.LOWER) {
      return rightArg.subtractR(this);
    }
 else     if (rightArg instanceof DoubleToken) {
      double result=_value - ((DoubleToken)rightArg).getValue();
      return new DoubleToken(result);
    }
 else     if (typeInfo == CPO.HIGHER) {
      DoubleToken tmp=(DoubleToken)this.convert(rightArg);
      double result=_value - tmp.getValue();
      return new DoubleToken(result);
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception ex) {
    String str="String_Node_Str";
    str=str + this.getClass().getName() + "String_Node_Str";
    str=str + rightArg.getClass().getName();
    throw new IllegalActionException(str + "String_Node_Str" + ex.getMessage());
  }
}
Program: 76582
Project: 76582
Buggy source:
/** 
 * Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param leftArg The token to add this Token to.
 * @exception IllegalActionException If the passed tokenis not of a type that can be added to this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtractR(Token leftArg) throws IllegalActionException {
  DoubleToken tmp=(DoubleToken)this.convert(leftArg);
  double result=_value - tmp.getValue();
  return new DoubleToken(result);
}

Fixed version (ground truth):
/** 
 * Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param leftArg The token to add this Token to.
 * @exception IllegalActionException If the passed tokenis not of a type that can be added to this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtractR(Token leftArg) throws IllegalActionException {
  DoubleToken tmp=(DoubleToken)this.convert(leftArg);
  double result=tmp.getValue() - _value;
  return new DoubleToken(result);
}
Program: 76583
Project: 76583
Buggy source:
/** 
 * Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param rightArg The token to subtract to this Token.
 * @exception IllegalActionException If the passed token isnot of a type that can be subtracted from this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtract(Token rightArg) throws IllegalActionException {
  int typeInfo=TypeCPO.compare(this,rightArg);
  try {
    if (typeInfo == CPO.LOWER) {
      return rightArg.addR(this);
    }
 else     if (rightArg instanceof IntToken) {
      int result=_value - ((IntToken)rightArg).getValue();
      return new IntToken(result);
    }
 else     if (typeInfo == CPO.HIGHER) {
      IntToken tmp=(IntToken)this.convert(rightArg);
      int result=_value - tmp.getValue();
      return new IntToken(result);
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception ex) {
    String str="String_Node_Str";
    str=str + this.getClass().getName() + "String_Node_Str";
    str=str + rightArg.getClass().getName();
    throw new IllegalActionException(str + "String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param rightArg The token to subtract to this Token.
 * @exception IllegalActionException If the passed token isnot of a type that can be subtracted from this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtract(Token rightArg) throws IllegalActionException {
  int typeInfo=TypeCPO.compare(this,rightArg);
  try {
    if (typeInfo == CPO.LOWER) {
      return rightArg.subtractR(this);
    }
 else     if (rightArg instanceof IntToken) {
      int result=_value - ((IntToken)rightArg).getValue();
      return new IntToken(result);
    }
 else     if (typeInfo == CPO.HIGHER) {
      IntToken tmp=(IntToken)this.convert(rightArg);
      int result=_value - tmp.getValue();
      return new IntToken(result);
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception ex) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + getClass().getName() + "String_Node_Str"+ rightArg.getClass().getName()+ "String_Node_Str"+ ex.getMessage());
  }
}
Program: 76584
Project: 76584
Buggy source:
/** 
 * Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param leftArg The token to add this Token to.
 * @exception IllegalActionException If the passed tokenis not of a type that can be added to this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtractR(Token leftArg) throws IllegalActionException {
  IntToken tmp=(IntToken)this.convert(leftArg);
  int result=_value - tmp.getValue();
  return new IntToken(result);
}

Fixed version (ground truth):
/** 
 * Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param leftArg The token to add this Token to.
 * @exception IllegalActionException If the passed tokenis not of a type that can be added to this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtractR(Token leftArg) throws IllegalActionException {
  IntToken tmp=(IntToken)this.convert(leftArg);
  int result=tmp.getValue() - _value;
  return new IntToken(result);
}
Program: 76585
Project: 76585
Buggy source:
/** 
 * Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param rightArg The token to subtract to this Token.
 * @exception IllegalActionException If the passed token isnot of a type that can be subtracted from this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtract(Token rightArg) throws IllegalActionException {
  long typeInfo=TypeCPO.compare(this,rightArg);
  try {
    if (typeInfo == CPO.LOWER) {
      return rightArg.addR(this);
    }
 else     if (rightArg instanceof LongToken) {
      long result=_value - ((LongToken)rightArg).getValue();
      return new LongToken(result);
    }
 else     if (typeInfo == CPO.HIGHER) {
      LongToken tmp=(LongToken)this.convert(rightArg);
      long result=_value - tmp.getValue();
      return new LongToken(result);
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception ex) {
    String str="String_Node_Str";
    str=str + this.getClass().getName() + "String_Node_Str";
    str=str + rightArg.getClass().getName();
    throw new IllegalActionException(str + "String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param rightArg The token to subtract to this Token.
 * @exception IllegalActionException If the passed token isnot of a type that can be subtracted from this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtract(Token rightArg) throws IllegalActionException {
  long typeInfo=TypeCPO.compare(this,rightArg);
  try {
    if (typeInfo == CPO.LOWER) {
      return rightArg.subtractR(this);
    }
 else     if (rightArg instanceof LongToken) {
      long result=_value - ((LongToken)rightArg).getValue();
      return new LongToken(result);
    }
 else     if (typeInfo == CPO.HIGHER) {
      LongToken tmp=(LongToken)this.convert(rightArg);
      long result=_value - tmp.getValue();
      return new LongToken(result);
    }
 else {
      throw new Exception();
    }
  }
 catch (  Exception ex) {
    String str="String_Node_Str";
    str=str + this.getClass().getName() + "String_Node_Str";
    str=str + rightArg.getClass().getName();
    throw new IllegalActionException(str + "String_Node_Str" + ex.getMessage());
  }
}
Program: 76586
Project: 76586
Buggy source:
/** 
 * Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param leftArg The token to add this Token to.
 * @exception IllegalActionException If the passed tokenis not of a type that can be added to this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtractR(Token leftArg) throws IllegalActionException {
  LongToken tmp=(LongToken)this.convert(leftArg);
  long result=_value - tmp.getValue();
  return new LongToken(result);
}

Fixed version (ground truth):
/** 
 * Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
 * @param leftArg The token to add this Token to.
 * @exception IllegalActionException If the passed tokenis not of a type that can be added to this Tokens value in a lossless fashion.
 * @return A new Token containing the result.
 */
public Token subtractR(Token leftArg) throws IllegalActionException {
  LongToken tmp=(LongToken)this.convert(leftArg);
  long result=tmp.getValue() - _value;
  return new LongToken(result);
}