nus-yam/ex-repair huggingface dataset:
Program: 76473
Project: 76473
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Sin newobj=(Sin)super.clone(ws);
    newobj.input=new TypedIOPort(this,"String_Node_Str",true,false);
    newobj.input.setDeclaredType(DoubleToken.class);
    newobj.output=new TypedIOPort(this,"String_Node_Str",false,true);
    newobj.output.setDeclaredType(DoubleToken.class);
    return newobj;
  }
 catch (  KernelException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Sin newobj=(Sin)super.clone(ws);
    newobj.input=(TypedIOPort)newobj.getPort("String_Node_Str");
    newobj.input.setDeclaredType(DoubleToken.class);
    newobj.output=(TypedIOPort)newobj.getPort("String_Node_Str");
    newobj.output.setDeclaredType(DoubleToken.class);
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}
Program: 76474
Project: 76474
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    TimePlot newobj=(TimePlot)super.clone(ws);
    newobj.input=new TypedIOPort(this,"String_Node_Str",true,false);
    newobj.input.setMultiport(true);
    newobj.input.setDeclaredType(DoubleToken.class);
    newobj.timed=new Parameter(this,"String_Node_Str",new BooleanToken(true));
    return newobj;
  }
 catch (  KernelException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    TimePlot newobj=(TimePlot)super.clone(ws);
    newobj.input=(TypedIOPort)newobj.getPort("String_Node_Str");
    newobj.input.setMultiport(true);
    newobj.input.setDeclaredType(DoubleToken.class);
    newobj.timed=(Parameter)newobj.getAttribute("String_Node_Str");
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}
Program: 76475
Project: 76475
Buggy source:
/** 
 * Put an array of objects in the queue and return true if this will not cause the capacity to be exceeded. Otherwise, do not put the object in the queue and return false.
 * @param element An array of objects to be put in the queue.
 * @return A boolean indicating success.
 */
public boolean put(Object element[]){
  if (_queuecapacity - _queuesize >= element.length) {
    int i;
    if (element.length <= (_queuecapacity - _queuefront)) {
      System.arraycopy(element,0,_queuearray,_queuefront,element.length);
      _queuefront+=element.length;
      if (_queuefront >= _queuecapacity)       _queuefront=_queuefront % _queuecapacity;
      _queuesize+=element.length;
    }
 else {
      System.arraycopy(element,0,_queuearray,_queuefront,_queuecapacity - _queuefront);
      System.arraycopy(element,_queuecapacity - _queuefront,_queuearray,0,element.length - (_queuecapacity - _queuefront));
      _queuefront+=element.length;
      if (_queuefront >= _queuecapacity)       _queuefront=_queuefront % _queuecapacity;
      _queuesize+=element.length;
    }
    return true;
  }
 else {
    Object newqueue[]=new Object[_queuecapacity * 2];
    System.arraycopy(_queuearray,0,newqueue,0,_queuecapacity);
    _queuearray=newqueue;
    _queuecapacity=_queuecapacity * 2;
    return put(element);
  }
}

Fixed version (ground truth):
/** 
 * Put an array of objects in the queue and return true if this will not cause the capacity to be exceeded. Otherwise, do not put the object in the queue and return false.
 * @param element An array of objects to be put in the queue.
 * @return A boolean indicating success.
 */
public boolean put(Object element[]){
  if (_queuecapacity - _queuesize >= element.length) {
    int i;
    if (element.length <= (_queuecapacity - _queuefront)) {
      System.arraycopy(element,0,_queuearray,_queuefront,element.length);
      _queuefront+=element.length;
      if (_queuefront >= _queuecapacity)       _queuefront=_queuefront % _queuecapacity;
      _queuesize+=element.length;
    }
 else {
      System.arraycopy(element,0,_queuearray,_queuefront,_queuecapacity - _queuefront);
      System.arraycopy(element,_queuecapacity - _queuefront,_queuearray,0,element.length - (_queuecapacity - _queuefront));
      _queuefront+=element.length;
      if (_queuefront >= _queuecapacity)       _queuefront=_queuefront % _queuecapacity;
      _queuesize+=element.length;
    }
    return true;
  }
 else {
    try {
      setCapacity(_queuecapacity * 2);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
    return put(element);
  }
}
Program: 76477
Project: 76477
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Ramp newobj=(Ramp)super.clone(ws);
    newobj.output=new TypedIOPort(this,"String_Node_Str",false,true);
    newobj.init=new Parameter(this,"String_Node_Str");
    newobj.step=new Parameter(this,"String_Node_Str");
    return newobj;
  }
 catch (  KernelException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then creates new ports and parameters.
 * @param ws The workspace for the new object.
 * @return A new actor.
 */
public Object clone(Workspace ws){
  try {
    Ramp newobj=(Ramp)super.clone(ws);
    newobj.output=(TypedIOPort)newobj.getPort("String_Node_Str");
    newobj.init=(Parameter)newobj.getAttribute("String_Node_Str");
    newobj.step=(Parameter)newobj.getAttribute("String_Node_Str");
    return newobj;
  }
 catch (  CloneNotSupportedException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}
Program: 76478
Project: 76478
Buggy source:
/** 
 * Prepare for firing and return true if firing can proceed. If there is no container, return false immediately.  Otherwise, the first step is to perform any pending mutations, and to initialize any actors that are added by those mutations.  This sequence is repeated until no more mutations are performed.  This way, the initialize() method in actors can perform mutations, and the mutations will be fully executed before proceeding. Then, if this is the local director of its container, invoke the prefire() methods of all its deeply contained actors, and return the logical AND of what they return.  If this is the executive director of its container, then invoke the prefire() method of the container and return what it returns.  Otherwise, return false. <p> This method should be invoked once per iteration, before any invocation of fire() in that iteration. It may produce output data. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @return True if the iteration can proceed.
 * @exception CloneNotSupportedException If the prefire() method of thecontainer or one of the deeply contained actors throws it.
 * @exception IllegalActionException If the prefire() method of thecontainer or one of the deeply contained actors throws it, or a pending mutation throws it.
 */
public boolean prefire() throws IllegalActionException {
}

Fixed version (ground truth):
/** 
 * Prepare for firing and return true if firing can proceed. If there is no container, return false immediately.  Otherwise, the first step is to perform any pending mutations, and to initialize any actors that are added by those mutations.  This sequence is repeated until no more mutations are performed.  This way, the initialize() method in actors can perform mutations, and the mutations will be fully executed before proceeding. Then, if this is the local director of its container, invoke the prefire() methods of all its deeply contained actors, and return the logical AND of what they return.  If this is the executive director of its container, then invoke the prefire() method of the container and return what it returns.  Otherwise, return false. <p> This method should be invoked once per iteration, before any invocation of fire() in that iteration. It may produce output data. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @return True if the iteration can proceed.
 * @exception CloneNotSupportedException If the prefire() method of thecontainer or one of the deeply contained actors throws it.
 * @exception IllegalActionException If the prefire() method of thecontainer or one of the deeply contained actors throws it, or a pending mutation throws it.
 */
public boolean prefire() throws IllegalActionException {
  CompositeActor c=getContainer();
  Director ed=c.getExecutiveDirector();
  boolean iterate;
  if (ed=null) {
    iterate=_advanceTime(_nextFiringTime);
    return true;
  }
 else {
    iterate=_advanceTime(ed.getCurrentTime());
  }
  return iterate;
}
Program: 76479
Project: 76479
Buggy source:
/** 
 * Construct an instance and initialize it by reading the specified stream.
 * @param input The input stream.
 * @exception IOException If an error occurs reading the input data(e.g. a premature end of file).
 */
public Audio(DataInputStream input) throws IOException {
  input.read(magic,0,4);
  offset=input.readInt();
  size=input.readInt();
  format=input.readInt();
  sampleRate=input.readInt();
  numChannels=input.readInt();
  info=new byte[offset - 24];
  input.read(info,0,offset - 24);
  if (magic[0] != 0x2E || magic[1] != 0x73 || magic[2] != 0x6E || magic[3] != 0x64) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (format != 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (numChannels != 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  audio=new byte[1][size];
  input.readFully(audio[0]);
}

Fixed version (ground truth):
/** 
 * Construct an instance and initialize it by reading the specified stream.
 * @param input The input stream.
 * @exception IOException If an error occurs reading the input data(e.g. a premature end of file).
 */
public Audio(DataInputStream input) throws IOException {
  input.read(magic,0,4);
  if (magic[0] != 0x2E || magic[1] != 0x73 || magic[2] != 0x6E || magic[3] != 0x64) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  offset=input.readInt();
  size=input.readInt();
  format=input.readInt();
  sampleRate=input.readInt();
  numChannels=input.readInt();
  if (offset < 0 || offset > 10000) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + offset + "String_Node_Str");
  }
  info=new byte[offset - 24];
  input.read(info,0,offset - 24);
  if (format != 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  if (numChannels != 1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  audio=new byte[1][size];
  input.readFully(audio[0]);
}
Program: 76483
Project: 76483
Buggy source:
/** 
 */
public void fire() throws IllegalActionException {
  boolean beginning=true;
  StringToken token;
  while (true) {
    token=new StringToken(_strValue);
    ConditionalBranch[] branches=new ConditionalBranch[2];
    branches[0]=new ConditionalReceive(true,_input,0,0);
    branches[1]=new ConditionalSend(true,_output,0,1,token);
    int br=chooseBranch(branches);
    if (br == 0) {
      token=(StringToken)branches[0].getToken();
      _strValue=token.stringValue();
    }
 else     if (br == -1) {
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 */
public void fire() throws IllegalActionException {
  if (_numInChannels == -1) {
    _numInChannels=0;
    Receiver[][] rcvrs=_input.getReceivers();
    for (int i=0; i < rcvrs.length; i++) {
      for (int j=0; j < rcvrs[i].length; j++) {
        _numInChannels++;
      }
    }
  }
  if (_numOutChannels == -1) {
    _numOutChannels=0;
    Receiver[][] rcvrs=_output.getRemoteReceivers();
    for (int i=0; i < rcvrs.length; i++) {
      for (int j=0; j < rcvrs[i].length; j++) {
        _numOutChannels++;
      }
    }
  }
  boolean beginning=true;
  StringToken token;
  while (true) {
    token=new StringToken(_strValue);
    int numBrchs=_numInChannels + _numOutChannels;
    ConditionalBranch[] branches=new ConditionalBranch[numBrchs];
    for (int i=0; i < _numInChannels; i++) {
      branches[i]=new ConditionalReceive(true,_input,i,i);
    }
    for (int i=0; i < _numOutChannels; i++) {
      branches[i + _numInChannels]=new ConditionalSend(true,_output,i,i + _numInChannels,token);
    }
    int br=chooseBranch(branches);
    if (br >= 0 && br < _numInChannels) {
      token=(StringToken)branches[br].getToken();
      _strValue=token.stringValue();
    }
 else     if (br >= _numInChannels && br < numBrchs) {
      _strValue="String_Node_Str";
    }
 else     if (br == -1) {
      return;
    }
  }
}
Program: 76484
Project: 76484
Buggy source:
/** 
 */
public void fire() throws IllegalActionException {
  while (true) {
    System.out.println(getName() + "String_Node_Str");
    _input.get(0);
    System.out.println(getName() + "String_Node_Str");
    waitForDeadlock();
    System.out.println(getName() + "String_Node_Str");
    _output.send(0,new Token());
  }
}

Fixed version (ground truth):
/** 
 */
public void fire() throws IllegalActionException {
  while (true) {
    System.out.println("String_Node_Str" + getName());
    _input.get(0);
    System.out.println("String_Node_Str" + getName());
    waitForDeadlock();
    System.out.println(getName() + "String_Node_Str");
    _output.send(0,new Token());
  }
}
Program: 76485
Project: 76485
Buggy source:
/** 
 */
public void accessMemory(boolean read) throws IllegalActionException {
  double delayTime=java.lang.Math.random() * 10.0;
  System.out.println(getName() + "String_Node_Str" + delayTime+ "String_Node_Str");
  delay(delayTime);
  IntToken iToken=new IntToken(_code);
  _requestOut.send(0,iToken);
  BooleanToken bToken=(BooleanToken)_requestIn.get(0);
  if (bToken.booleanValue()) {
    if (read) {
      _memoryIn.get(0);
    }
 else {
      StringToken strToken=new StringToken(getName());
      _memoryOut.send(0,strToken);
    }
    return;
  }
  accessMemory(read);
}

Fixed version (ground truth):
/** 
 */
public void accessMemory(boolean read) throws IllegalActionException {
  System.out.println("String_Node_Str" + getName());
  double delayTime=java.lang.Math.random() * 10.0;
  System.out.println(getName() + "String_Node_Str" + delayTime+ "String_Node_Str");
  delay(delayTime);
  System.out.println(getName() + "String_Node_Str");
  System.out.println("String_Node_Str" + getName());
  IntToken iToken=new IntToken(_code);
  _requestOut.broadcast(iToken);
  System.out.println(getName() + "String_Node_Str");
  System.out.println("String_Node_Str" + getName());
  BooleanToken bToken=(BooleanToken)_requestIn.get(0);
  if (bToken.booleanValue()) {
    System.out.println(getName() + "String_Node_Str");
    if (read) {
      _memoryIn.get(0);
    }
 else {
      StringToken strToken=new StringToken(getName());
      _memoryOut.broadcast(strToken);
    }
    return;
  }
  System.out.println("String_Node_Str" + getName());
  accessMemory(read);
}
Program: 76486
Project: 76486
Buggy source:
/** 
 * Convert mu-255 companded representation of an audio sample into an integer linear representation.  Mu law is the standard used in Sun .au files as well as throughout the telephone network. This implementation is based on the web page by <a href=mailto:donahu@cooper.edu>Billy Donahue</a>: <a href=http://www.cooper.edu/~donahu/auformat/auFormat.html> http://www.cooper.edu/~donahu/auformat/auFormat.html</a>. The resulting integer values are scaled to be in the range -31616 to 31616.  This uses the low order 16 bits of the resulting integer, and thus provides a convenient 16-bit linear encoding. <p> The mu-255 representation is a byte SEEEMMMM where S is the sign bit, EEE is the three-bit exponent, and MMMM is the four-bit mantissa.  The bits are flipped, so that the binary 10000000 is the largest positive number and 00000000 is the largest negative number. <p> If you have called setZeroTrap() with a <i>true</i> argument, then this will not be an exact inverse of lin2mu because the zero code is interpreted as being the largest negative number, -31,616.
 * @param b A mu-255 representation of the sample.
 * @return A linear representation of the sample.
 */
public static int mu2lin(byte b){
  int mu=b ^ 0xFF;
  int sign=(mu & 0x80) >> 7;
  int exponent=(mu & 0x70) >> 4;
  int mantissa=(mu & 0x0F);
  int linear=(mantissa << (exponent + 1)) - 0x20 + (0x20 << exponent);
  linear<<=2;
  return (sign == 1) ? -linear : linear;
}

Fixed version (ground truth):
/** 
 * Convert mu-255 companded representation of an audio sample into an integer linear representation.  Mu law is the standard used in Sun .au files as well as throughout the telephone network. This implementation is based on the web page by <a href=mailto:donahu@cooper.edu>Billy Donahue</a>: <a href=http://www.cooper.edu/~donahu/auformat/auFormat.html> http://www.cooper.edu/~donahu/auformat/auFormat.html</a>. The resulting integer values are scaled to be in the range -31616 to 31616.  This uses the low order 16 bits of the resulting integer, and thus provides a convenient 16-bit linear encoding. <p> The mu-255 representation is a byte SEEEMMMM where S is the sign bit, EEE is the three-bit exponent, and MMMM is the four-bit mantissa.  The bits are flipped, so that the binary 10000000 is the largest positive number and 00000000 is the largest negative number. <p> If you have called setZeroTrap() with a <i>true</i> argument, then this will not be an exact inverse of lin2mu because the zero code is interpreted as being the largest negative number, -31616.
 * @param b A mu-255 representation of the sample.
 * @return A linear representation of the sample.
 */
public static int mu2lin(byte b){
  int mu=b ^ 0xFF;
  int sign=(mu & 0x80) >> 7;
  int exponent=(mu & 0x70) >> 4;
  int mantissa=(mu & 0x0F);
  int linear=(mantissa << (exponent + 1)) - 0x20 + (0x20 << exponent);
  linear<<=2;
  return (sign == 1) ? -linear : linear;
}
Program: 76487
Project: 76487
Buggy source:
/** 
 * Display basic information about the application.
 */
protected void _about(){
  Message message=new Message("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  message.setTitle("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Display basic information about the application.
 */
protected void _about(){
  Message message=new Message("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  message.setTitle("String_Node_Str");
}
Program: 76488
Project: 76488
Buggy source:
/** 
 * Send a token to all connected receivers. The transfer is accomplished by calling the put() method of the destination receivers.  The destination receivers are obtained by calling getRemoteReceivers(). If there are no destination receivers, then nothing is sent. This method is read-synchronized on the workspace.
 * @param token The token to send
 * @exception IllegalActionException If the port is not an output.
 * @exception NoRoomException If a send to one of the channels throwsit.
 */
public void broadcast(Token token) throws IllegalActionException, NoRoomException {
  try {
    workspace().getReadAccess();
    if (!isOutput()) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
    Receiver farRecs[][]=getRemoteReceivers();
    if (farRecs == null) {
      return;
    }
    for (int j=0; j < farRecs.length; j++) {
      send(j,token);
    }
  }
  finally {
    workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Send a token to all connected receivers. The transfer is accomplished by calling getRemoteReceivers() to determine the number of channels with valid receivers and then calling send on the appropriate channels.   It would probably be faster to call put() directly on the receivers. If there are no destination receivers, then nothing is sent. This method is read-synchronized on the workspace.
 * @param token The token to send
 * @exception IllegalActionException If the port is not an output.
 * @exception NoRoomException If a send to one of the channels throwsit.
 */
public void broadcast(Token token) throws IllegalActionException, NoRoomException {
  try {
    workspace().getReadAccess();
    if (!isOutput()) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
    Receiver farRecs[][]=getRemoteReceivers();
    if (farRecs == null) {
      return;
    }
    for (int j=0; j < farRecs.length; j++) {
      send(j,token);
    }
  }
  finally {
    workspace().doneReading();
  }
}
Program: 76489
Project: 76489
Buggy source:
/** 
 * Send the specified token to all receivers connected to the specified channel.  The first receiver gets the actual token, while subsequent ones get a clone.  If there are no receivers, then do nothing. The transfer is accomplished by calling the put() method of the remote receivers. <p> Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put.
 * @param channelindex The index of the channel, from 0 to width-1
 * @param token The token to send
 * @exception NoRoomException If there is no room in the receiver.
 * @exception IllegalActionException If the port is not an output or ifthe index is out of range.
 */
public void send(int channelindex,Token token) throws IllegalActionException, NoRoomException {
  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;
  }
  finally {
    workspace().doneReading();
  }
  for (int j=0; j < farRec[channelindex].length; j++) {
    farRec[channelindex][j].put(token);
  }
}

Fixed version (ground truth):
/** 
 * Send the specified token to all receivers connected to the specified channel.  Tokens are in general immutable, so each receiver is given a reference to the same token and no clones are made. If there are no receivers, then do nothing. The transfer is  accomplished by calling the put() method of the remote receivers. <p> Some of this method is read-synchronized on the workspace. Since it is possible for a thread to block while executing a put, it is important that the thread does not hold read access on the workspace when it is blocked. Thus this method releases read access on the workspace before calling put.
 * @param channelindex The index of the channel, from 0 to width-1
 * @param token The token to send
 * @exception NoRoomException If there is no room in the receiver.
 * @exception IllegalActionException If the port is not an output or ifthe index is out of range.
 */
public void send(int channelindex,Token token) throws IllegalActionException, NoRoomException {
  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;
  }
  finally {
    workspace().doneReading();
  }
  for (int j=0; j < farRec[channelindex].length; j++) {
    farRec[channelindex][j].put(token);
  }
}
Program: 76490
Project: 76490
Buggy source:
/** 
 * Return a new receiver of a type compatible with this director.
 * @return A new ODReceiver.
 */
public Receiver newReceiver(){
  ODReceiver rcvr=new ODReceiver();
  if (_completionTime != -1.0) {
    rcvr.setCompletionTime(_completionTime);
  }
  return rcvr;
}

Fixed version (ground truth):
/** 
 * Return a new receiver of a type compatible with this director.
 * @return A new ODReceiver.
 */
public Receiver newReceiver(){
  ODReceiver rcvr=new ODReceiver();
  rcvr.setCompletionTime(_completionTime);
  System.out.println("String_Node_Str" + _completionTime);
  return rcvr;
}
Program: 76491
Project: 76491
Buggy source:
/** 
 * Do a blocking write to the queue. Block if the queue is full.  Associate the given time stamp with the token. 
 * @param token The token to put on the queue.
 * @param time The time stamp of the token.FIXME: What if receiver is full but we want to put a token with timestamp = -1 inside??
 */
public void put(Token token,double time){
  Workspace workspace=getContainer().workspace();
  ODActor actor=(ODActor)getContainer().getContainer();
  ODDirector director=(ODDirector)actor.getDirector();
synchronized (this) {
    if (time > getCompletionTime()) {
      time=-1.0;
      token=null;
    }
    if (!super.hasRoom()) {
      director.addWriteBlock();
      while (!_terminate && !super.hasRoom()) {
        notifyAll();
        workspace.wait(this);
      }
    }
 else     if (!_terminate) {
      super.put(token,time);
      notifyAll();
      return;
    }
    if (_terminate) {
      director.removeWriteBlock();
      new TerminateProcessException(getContainer(),"String_Node_Str");
    }
 else {
      director.removeWriteBlock();
      super.put(token,time);
      notifyAll();
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 * Do a blocking write to the queue. Block if the queue is full.  Associate the given time stamp with the token. 
 * @param token The token to put on the queue.
 * @param time The time stamp of the token.FIXME: What if receiver is full but we want to put a token with timestamp = -1 inside??
 */
public void put(Token token,double time){
  Workspace workspace=getContainer().workspace();
  ODActor actor=(ODActor)getContainer().getContainer();
  ODDirector director=(ODDirector)actor.getDirector();
synchronized (this) {
    if (time > getCompletionTime() && getCompletionTime() != -5.0) {
      time=-1.0;
      token=null;
    }
    if (!super.hasRoom()) {
      director.addWriteBlock();
      while (!_terminate && !super.hasRoom()) {
        notifyAll();
        workspace.wait(this);
      }
    }
 else     if (!_terminate) {
      super.put(token,time);
      notifyAll();
      return;
    }
    if (_terminate) {
      director.removeWriteBlock();
      new TerminateProcessException(getContainer(),"String_Node_Str");
    }
 else {
      director.removeWriteBlock();
      super.put(token,time);
      notifyAll();
      return;
    }
  }
}
Program: 76492
Project: 76492
Buggy source:
/** 
 */
public double getLastTime(){
  return _lastTime;
}

Fixed version (ground truth):
/** 
 * Return the lastTime value.
 * @return double The value of the lastTime flag.
 */
public double getLastTime(){
  return _lastTime;
}
Program: 76493
Project: 76493
Buggy source:
/** 
 * Return the container. 
 */
public IOPort getContainer(){
  return _container;
}

Fixed version (ground truth):
/** 
 * Return the container. 
 * @return IOPort The containing IOPort.
 */
public IOPort getContainer(){
  return _container;
}
Program: 76494
Project: 76494
Buggy source:
/** 
 * Get the completion time of this receiver. 
 */
public synchronized double getCompletionTime(){
  return _completionTime;
}

Fixed version (ground truth):
/** 
 * Get the completion time of this receiver. 
 * @return double The completion time.
 */
public synchronized double getCompletionTime(){
  return _completionTime;
}
Program: 76495
Project: 76495
Buggy source:
/** 
 * Take the first token (the oldest one) off the queue and return it. If the queue is empty, throw an exception. If there are other tokens left on the queue, set the rcvr time to equal that of the new leading token.
 * @exception NoTokenException If the queue is empty.
 */
public Token get(){
  ODActor actor=(ODActor)getContainer().getContainer();
  Token token=null;
synchronized (this) {
    Event event=(Event)_queue.take();
    if (event == null) {
      throw new NoTokenException(getContainer(),"String_Node_Str");
    }
    token=event.getToken();
    if (getSize() > 0) {
      Event nextEvent=(Event)_queue.get(0);
      _rcvrTime=nextEvent.getTime();
    }
    RcvrTimeTriple triple;
    triple=new RcvrTimeTriple(this,_rcvrTime,_priority);
    actor.updateRcvrTable(triple);
  }
  return token;
}

Fixed version (ground truth):
/** 
 * Take the first token (the oldest one) off the queue and return it. If the queue is empty, throw a NoTokenException. If there are other tokens left on the queue, set the rcvr time to equal that of the new leading token.
 * @exception NoTokenException If the queue is empty.
 */
public Token get(){
  ODActor actor=(ODActor)getContainer().getContainer();
  Token token=null;
synchronized (this) {
    Event event=(Event)_queue.take();
    if (event == null) {
      throw new NoTokenException(getContainer(),"String_Node_Str");
    }
    token=event.getToken();
    if (getSize() > 0) {
      Event nextEvent=(Event)_queue.get(0);
      _rcvrTime=nextEvent.getTime();
    }
    RcvrTimeTriple triple;
    triple=new RcvrTimeTriple(this,_rcvrTime,_priority);
    actor.updateRcvrTable(triple);
  }
  return token;
}
Program: 76496
Project: 76496
Buggy source:
/** 
 * Get the priority of this receiver. 
 */
public synchronized int getPriority(){
  return _priority;
}

Fixed version (ground truth):
/** 
 * Return the priority of this receiver. 
 * @return The priority of this receiver.
 */
public synchronized int getPriority(){
  return _priority;
}
Program: 76497
Project: 76497
Buggy source:
/** 
 * Get the queue capacity. 
 */
public int getCapacity(){
  return _queue.getCapacity();
}

Fixed version (ground truth):
/** 
 * Get the queue capacity. 
 * @return int The queue capacity.
 */
public int getCapacity(){
  return _queue.getCapacity();
}
Program: 76498
Project: 76498
Buggy source:
/** 
 * Override the base class to ensure that the proposed container is a ComponentEntity.
 * @param entity The proposed container.
 * @exception IllegalActionException If the container is not aComponentEntity, or it has no name, or the port and container are not in the same workspace.
 * @exception NameDuplicationException If the container already hasa port with the name of this port.
 */
public void setContainer(Entity container) throws IllegalActionException, NameDuplicationException {
  if (!(container instanceof ComponentEntity)) {
    throw new IllegalActionException(container,this,"String_Node_Str");
  }
  super.setContainer(container);
}

Fixed version (ground truth):
/** 
 * Override the base class to ensure that the proposed container is a ComponentEntity.
 * @param entity The proposed container.
 * @exception IllegalActionException If the container is not aComponentEntity, or it has no name, or the port and container are not in the same workspace.
 * @exception NameDuplicationException If the container already hasa port with the name of this port.
 */
public void setContainer(Entity container) throws IllegalActionException, NameDuplicationException {
  if (!(container instanceof ComponentEntity) && (container != null)) {
    throw new IllegalActionException(container,this,"String_Node_Str");
  }
  super.setContainer(container);
}
Program: 76499
Project: 76499
Buggy source:
/** 
 * Executes the code in this actor. This actor waits for a  customer to arrive, then delays for a random time,  representing the service times, described by an  exponential distribution. A customer arrival is marked by  the arrival of a message at the input channel of the actor.  It then repeats. This process continues executing until a TerminateProcessException is thrown.
 * @exception IllegalActionException If an error occurs during executing the process.
 */
public void fire() throws IllegalActionException {
  Random rand=new Random();
  double interval=0;
  try {
    while (true) {
      Token t=_input.get(0);
      double rate=1.0;
      interval=Math.exp(-(rand.nextDouble()) * rate);
      interval=(int)(interval * 1000);
      delay(interval / 1000);
      System.out.println(getName() + "String_Node_Str" + t.toString());
    }
    System.out.println("String_Node_Str" + getName() + "String_Node_Str");
    return;
  }
 catch (  NoTokenException ex) {
    throw new IllegalActionException(getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Executes the code in this actor. This actor waits for a  customer to arrive, then delays for a random time,  representing the service times, described by an  exponential distribution. A customer arrival is marked by  the arrival of a message at the input channel of the actor.  It then repeats. This process continues executing until a TerminateProcessException is thrown.
 * @exception IllegalActionException If an error occurs during executing the process.
 */
public void fire() throws IllegalActionException {
  Random rand=new Random();
  double interval=0;
  try {
    while (true) {
      Token t=_input.get(0);
      double rate=1.0;
      interval=Math.exp(-(rand.nextDouble()) * rate);
      interval=(int)(interval * 1000);
      delay(interval / 1000);
      System.out.println(getName() + "String_Node_Str" + t.toString());
    }
  }
 catch (  NoTokenException ex) {
    throw new IllegalActionException(getName() + "String_Node_Str");
  }
}
Program: 76502
Project: 76502
Buggy source:
/** 
 * Construct a DESampler actor.
 * @param container The composite actor that this actor belongs too.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public DESampler(TypedCompositeActor container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  output=new DEIOPort(this,"String_Node_Str",false,true);
  input=new DEIOPort(this,"String_Node_Str",true,false);
  clock=new DEIOPort(this,"String_Node_Str",true,false);
  clock.setDeclaredType(Token.class);
  clock.triggers(output);
}

Fixed version (ground truth):
/** 
 * Construct a DESampler actor with the specified initial token.
 * @param container The composite actor that this actor belongs too.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public DESampler(TypedCompositeActor container,String name,Token initToken) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  if (initToken != null) {
    _initToken=new Parameter(this,"String_Node_Str",initToken);
  }
 else {
    _initToken=null;
  }
  output=new DEIOPort(this,"String_Node_Str",false,true);
  input=new DEIOPort(this,"String_Node_Str",true,false);
  clock=new DEIOPort(this,"String_Node_Str",true,false);
  clock.setDeclaredType(Token.class);
  clock.triggers(output);
}
Program: 76504
Project: 76504
Buggy source:
/** 
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  input.allowPendingTokens(true);
  _busyUntil=Double.NEGATIVE_INFINITY;
  _tokenBeingServed=null;
}

Fixed version (ground truth):
/** 
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  input.allowPendingTokens(true);
  while (input.hasToken(0)) {
    input.get(0);
  }
  _busyUntil=Double.NEGATIVE_INFINITY;
  _tokenBeingServed=null;
}
Program: 76505
Project: 76505
Buggy source:
/** 
 * Make a token available to the get() method. Normally, only a director should use this method. It uses it when its current time matches the time stamp of the token.
 * @param token The token to make available.
 */
protected void _triggerEvent(Token token){
  _tokens.insertFirst(token);
}

Fixed version (ground truth):
/** 
 * Make a token available to the get() method. Normally, only a director should use this method. It uses it when its current time matches the time stamp of the token.
 * @param token The token to make available.
 */
protected void _triggerEvent(Token token){
  _tokens.insertLast(token);
}
Program: 76506
Project: 76506
Buggy source:
/** 
 * Put an event into the event queue with the specified destination receiver, transferred token, time stamp and depth. The depth  is used to prioritize events that have equal time stamps.  A smaller depth corresponds to a higher priority.
 * @param receiver The destination receiver.
 * @param token The token destined for that receiver.
 * @param time The time stamp of the event.
 * @param depth The depth.
 * @exception IllegalActionException If the delay is negative.
 */
protected void _enqueueEvent(DEReceiver receiver,Token token,double time,long depth) throws IllegalActionException {
  if (time < _currentTime) {
    throw new IllegalActionException(getContainer(),"String_Node_Str");
  }
  DESortKey key=new DESortKey(time,depth);
  DEEvent event=new DEEvent(receiver,token,key);
  if (DEBUG) {
    System.out.print(getFullName() + "String_Node_Str");
    System.out.println("String_Node_Str" + receiver.getContainer().description(FULLNAME) + "String_Node_Str"+ ((Entity)event.actor).description(FULLNAME)+ "String_Node_Str"+ time+ "String_Node_Str");
  }
  _cQueue.put(key,event);
}

Fixed version (ground truth):
/** 
 * Put an event into the event queue with the specified destination receiver, transferred token, time stamp and depth. The depth  is used to prioritize events that have equal time stamps.  A smaller depth corresponds to a higher priority.
 * @param receiver The destination receiver.
 * @param token The token destined for that receiver.
 * @param time The time stamp of the event.
 * @param depth The depth.
 * @exception IllegalActionException If the delay is negative.
 */
protected void _enqueueEvent(DEReceiver receiver,Token token,double time,long depth) throws IllegalActionException {
  if (time < _currentTime) {
    throw new IllegalActionException(getContainer(),"String_Node_Str");
  }
  DESortKey key=new DESortKey(time,depth);
  DEEvent event=new DEEvent(receiver,token,key);
  if (DEBUG) {
    System.out.print(getFullName() + "String_Node_Str");
    System.out.println("String_Node_Str" + receiver.getContainer().description(FULLNAME) + "String_Node_Str"+ ((Entity)event.actor).description(FULLNAME)+ "String_Node_Str"+ time+ "String_Node_Str"+ depth+ "String_Node_Str");
  }
  _cQueue.put(key,event);
}
Program: 76507
Project: 76507
Buggy source:
/** 
 * Set current time to zero, calculate priorities for simultaneous events, and invoke the initialize() methods of all actors deeply contained by the container.  To be able to calculate the priorities, it is essential that the graph not have a delay-free loop.  If it does, then this can be corrected by inserting a DEDelay actor with a zero-valued delay.  This has the effect of breaking the loop for the purposes of calculating priorities, without introducing a time delay. <p> This method should be invoked once per execution, before any iteration. Actors may produce output data in their initialize() methods, or more commonly, they may schedule pure events. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If there is a delay-free loop, orif the initialize() method of the container or one of the deeply contained actors throws it.
 */
public void initialize() throws IllegalActionException {
  _cQueue=new CalendarQueue(new DECQComparator());
  _dag=new DirectedAcyclicGraph();
  _currentTime=0.0;
  _startTime=Double.MAX_VALUE;
  _startTimeInitialized=false;
  _constructDirectedGraph();
  if (!_dag.isAcyclic()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  super.initialize();
  _computeDepth();
  if (isEmbedded() && !_cQueue.isEmpty()) {
    _requestFiring();
  }
}

Fixed version (ground truth):
/** 
 * Set current time to zero, calculate priorities for simultaneous events, and invoke the initialize() methods of all actors deeply contained by the container.  To be able to calculate the priorities, it is essential that the graph not have a delay-free loop.  If it does, then this can be corrected by inserting a DEDelay actor with a zero-valued delay.  This has the effect of breaking the loop for the purposes of calculating priorities, without introducing a time delay. <p> This method should be invoked once per execution, before any iteration. Actors may produce output data in their initialize() methods, or more commonly, they may schedule pure events. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If there is a delay-free loop, orif the initialize() method of the container or one of the deeply contained actors throws it.
 */
public void initialize() throws IllegalActionException {
  _cQueue=new CalendarQueue(new DECQComparator());
  _dag=new DirectedAcyclicGraph();
  _currentTime=0.0;
  _startTime=Double.MAX_VALUE;
  _startTimeInitialized=false;
  _constructDirectedGraph();
  if (!_dag.isAcyclic()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  _isInitialized=false;
  super.initialize();
  _isInitialized=true;
  _computeDepth();
  if (isEmbedded() && !_cQueue.isEmpty()) {
    _requestFiring();
  }
}
Program: 76508
Project: 76508
Buggy source:
/** 
 * Schedule an actor to be fired after the specified delay. If the delay argument is equal to zero, then the actor will be refired after all actors enabled at current time are fired.
 * @param actor The scheduled actor to fire.
 * @param delay The scheduled time to fire.
 * @exception IllegalActionException If the delay is negative.
 */
public void fireAfterDelay(Actor actor,double delay) throws IllegalActionException {
  if (delay == 0) {
    this._enqueueEvent(actor,getCurrentTime(),Long.MAX_VALUE);
    return;
  }
  long maxdepth=-1;
  Enumeration iports=actor.inputPorts();
  while (iports.hasMoreElements()) {
    IOPort p=(IOPort)iports.nextElement();
    Receiver[][] r=p.getReceivers();
    if (r == null)     continue;
    DEReceiver rr=(DEReceiver)r[0][0];
    if (rr._depth > maxdepth) {
      maxdepth=rr._depth;
    }
  }
  this._enqueueEvent(actor,getCurrentTime() + delay,maxdepth + 1);
}

Fixed version (ground truth):
/** 
 * Schedule an actor to be fired after the specified delay. If the delay argument is equal to zero, then the actor will be refired after all actors enabled at current time are fired.
 * @param actor The scheduled actor to fire.
 * @param delay The scheduled time to fire.
 * @exception IllegalActionException If the delay is negative.
 */
public void fireAfterDelay(Actor actor,double delay) throws IllegalActionException {
  if (delay == 0 && _isInitialized) {
    this._enqueueEvent(actor,getCurrentTime(),Long.MAX_VALUE);
    return;
  }
  long maxdepth=-1;
  Enumeration iports=actor.inputPorts();
  while (iports.hasMoreElements()) {
    IOPort p=(IOPort)iports.nextElement();
    Receiver[][] r=p.getReceivers();
    if (r == null)     continue;
    DEReceiver rr=(DEReceiver)r[0][0];
    if (rr._depth > maxdepth) {
      maxdepth=rr._depth;
    }
  }
  this._enqueueEvent(actor,getCurrentTime() + delay,maxdepth + 1);
}
Program: 76510
Project: 76510
Buggy source:
/** 
 * Perform the mutation represented by this object. This is an abstract method, so subclasses must override this method and use it to construct the queue of pending topology events.
 */
public abstract void constructEventQueue() throws Exception ;

Fixed version (ground truth):
/** 
 * Perform the mutation represented by this object. This is an abstract method, so subclasses must override this method and use it to construct the queue of pending topology events.
 * @exception Exception Throw in the derived classes.
 */
public abstract void constructEventQueue() throws Exception ;
Program: 76511
Project: 76511
Buggy source:
/** 
 * Undo the topology change represented by this event.
 */
public void undoTopologyChange() throws Exception {
switch (getID()) {
case ENTITY_ADDED:
    _componentEntity.setContainer(null);
  break;
case ENTITY_REMOVED:
_componentEntity.setContainer(_compositeEntity);
break;
case PORT_ADDED:
_port.setContainer(null);
break;
case PORT_REMOVED:
_port.setContainer(_entity);
break;
case PORT_LINKED:
_port.unlink(_relation);
break;
case PORT_UNLINKED:
_port.link(_relation);
break;
case RELATION_ADDED:
_componentRelation.setContainer(null);
break;
case RELATION_REMOVED:
_componentRelation.setContainer(_compositeEntity);
break;
}
}

Fixed version (ground truth):
/** 
 * Undo the topology change represented by this event.
 * @exception Exception Thrown if setting the ComponentEntity containerto null fails.
 */
public void undoTopologyChange() throws Exception {
switch (getID()) {
case ENTITY_ADDED:
    _componentEntity.setContainer(null);
  break;
case ENTITY_REMOVED:
_componentEntity.setContainer(_compositeEntity);
break;
case PORT_ADDED:
_port.setContainer(null);
break;
case PORT_REMOVED:
_port.setContainer(_entity);
break;
case PORT_LINKED:
_port.unlink(_relation);
break;
case PORT_UNLINKED:
_port.link(_relation);
break;
case RELATION_ADDED:
_componentRelation.setContainer(null);
break;
case RELATION_REMOVED:
_componentRelation.setContainer(_compositeEntity);
break;
}
}
Program: 76512
Project: 76512
Buggy source:
/** 
 * This method increases the number of paused threads and checks if the entire simulation is paused.
 */
public synchronized void increasePausedCount(){
  _actorsPaused++;
  _checkForPause();
}

Fixed version (ground truth):
/** 
 * This method increases the number of paused threads and checks if the entire model has sucessfuly paused.
 */
public synchronized void increasePausedCount(){
  _actorsPaused++;
  _checkForPause();
}
Program: 76513
Project: 76513
Buggy source:
protected boolean _handleDeadlock() throws IllegalActionException {
  Workspace worksp=workspace();
synchronized (this) {
    while (!_deadlock) {
      worksp.wait(this);
    }
  }
  _notdone=false;
  return true;
}

Fixed version (ground truth):
/** 
 * Handles and responds to deadlocks. In this base class it  returns true when deadlock has been detected. Override this  method to obtain domain specific handling of deadlocks.
 * @return true for termination.
 * @exception IllegalActionException If a derived class throws it.
 */
protected boolean _handleDeadlock() throws IllegalActionException {
  Workspace worksp=workspace();
synchronized (this) {
    while (!_deadlock) {
      worksp.wait(this);
    }
  }
  _notdone=false;
  return true;
}