nus-yam/ex-repair huggingface dataset:
Program: 76305
Project: 76305
Buggy source:
public static final String toString(final int modifier){
  StringBuffer modString=new StringBuffer();
  if (modifier == NO_MOD)   return "String_Node_Str";
  if ((modifier & PUBLIC_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & PROTECTED_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & PRIVATE_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & ABSTRACT_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & FINAL_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & NATIVE_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & SYNCHRONIZED_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & TRANSIENT_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & VOLATILE_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & STATIC_MOD) != 0)   modString.append("String_Node_Str");
  return modString.toString();
}

Fixed version (ground truth):
public static final String toString(final int modifier){
  StringBuffer modString=new StringBuffer();
  if (modifier == NO_MOD)   return "String_Node_Str";
  if ((modifier & PUBLIC_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & PROTECTED_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & PRIVATE_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & ABSTRACT_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & FINAL_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & NATIVE_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & SYNCHRONIZED_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & TRANSIENT_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & VOLATILE_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & STATIC_MOD) != 0)   modString.append("String_Node_Str");
  if ((modifier & STRICTFP_MOD) != 0)   modString.append("String_Node_Str");
  return modString.toString();
}
Program: 76306
Project: 76306
Buggy source:
public static final void checkConstantFieldModifiers(final int modifiers){
  if ((modifiers & ~(PUBLIC_MOD | STATIC_MOD | FINAL_MOD)) != 0) {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public static final void checkConstantFieldModifiers(final int modifiers){
  if ((modifiers & ~(PUBLIC_MOD | STATIC_MOD | FINAL_MOD)) != 0) {
    throw new RuntimeException("String_Node_Str" + toString(modifiers));
  }
}
Program: 76307
Project: 76307
Buggy source:
public static final void checkFieldModifiers(int modifiers){
  if ((modifiers & ~(PUBLIC_MOD | PROTECTED_MOD | PRIVATE_MOD| STATIC_MOD| FINAL_MOD| TRANSIENT_MOD| VOLATILE_MOD)) != 0) {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public static final void checkFieldModifiers(final int modifiers){
  if ((modifiers & ~(PUBLIC_MOD | PROTECTED_MOD | PRIVATE_MOD| STATIC_MOD| FINAL_MOD| TRANSIENT_MOD| VOLATILE_MOD)) != 0) {
    throw new RuntimeException("String_Node_Str" + toString(modifiers));
  }
}
Program: 76308
Project: 76308
Buggy source:
public static final void checkConstructorModifiers(final int modifiers){
  if ((modifiers & ~(PUBLIC_MOD | PROTECTED_MOD | PRIVATE_MOD)) != 0) {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public static final void checkConstructorModifiers(final int modifiers){
  if ((modifiers & ~(PUBLIC_MOD | PROTECTED_MOD | PRIVATE_MOD)) != 0) {
    throw new RuntimeException("String_Node_Str" + toString(modifiers));
  }
}
Program: 76309
Project: 76309
Buggy source:
/** 
 * Open the document from its current file.  If successful, add a new Page to the document containing the model parsed from the current file.
 * @throws Exception  If there is no file, or if the I/O operation failed.
 */
public void open() throws Exception {
  if (getFile() == null) {
    throw new IllegalStateException("String_Node_Str" + getTitle() + "String_Node_Str");
  }
  String filename=getFile().getCanonicalPath();
  URL urlbase=new URL("String_Node_Str");
  URL schematicURL=new URL(urlbase,filename);
  System.out.println("String_Node_Str" + schematicURL);
  MoMLParser parser=new MoMLParser();
  CompositeEntity toplevel=(CompositeEntity)parser.parse(schematicURL,schematicURL.openStream());
  setGraph(toplevel);
}

Fixed version (ground truth):
/** 
 * Open the document from its current file.  If successful, add a new Page to the document containing the model parsed from the current file.
 * @throws Exception  If there is no file, or if the I/O operation failed.
 */
public void open() throws Exception {
  if (getFile() == null) {
    throw new IllegalStateException("String_Node_Str" + getTitle() + "String_Node_Str");
  }
  String filename=getFile().getAbsolutePath();
  URL schematicURL=new URL("String_Node_Str",null,filename);
  MoMLParser parser=new MoMLParser();
  CompositeEntity toplevel=(CompositeEntity)parser.parse(schematicURL,new FileInputStream(getFile()));
  setGraph(toplevel);
}
Program: 76310
Project: 76310
Buggy source:
/** 
 * Check if the value of this token is strictly less than that of the argument token.
 * @param arg A ScalarToken.
 * @return A BooleanToken with value true if this token is strictlyless than the argument.
 * @exception IllegalActionException If the type of the argument tokenis incomparable with the type of this token.
 */
public BooleanToken isLessThan(ScalarToken arg) throws IllegalActionException {
  int typeInfo=TypeLattice.compare(this,arg);
  if (typeInfo == CPO.INCOMPARABLE) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ arg.getType());
  }
  if (typeInfo == CPO.LOWER) {
    return arg.isLessThan(this);
  }
  ScalarToken longArg=arg;
  if (typeInfo == CPO.HIGHER) {
    longArg=(ScalarToken)convert(arg);
  }
  if (_value < longArg.intValue()) {
    return new BooleanToken(true);
  }
  return new BooleanToken(false);
}

Fixed version (ground truth):
/** 
 * Check if the value of this token is strictly less than that of the argument token.
 * @param arg A ScalarToken.
 * @return A BooleanToken with value true if this token is strictlyless than the argument.
 * @exception IllegalActionException If the type of the argument tokenis incomparable with the type of this token.
 */
public BooleanToken isLessThan(ScalarToken arg) throws IllegalActionException {
  int typeInfo=TypeLattice.compare(this,arg);
  if (typeInfo == CPO.INCOMPARABLE) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ arg.getType());
  }
  if (typeInfo == CPO.LOWER) {
    return arg.isLessThan(this);
  }
  ScalarToken longArg=arg;
  if (typeInfo == CPO.HIGHER) {
    longArg=(ScalarToken)convert(arg);
  }
  if (_value < longArg.longValue()) {
    return new BooleanToken(true);
  }
  return new BooleanToken(false);
}
Program: 76312
Project: 76312
Buggy source:
/** 
 * Output the sample value of the sound file corresponding to the current index.
 */
public boolean postfire() throws IllegalActionException {
  try {
    int i;
    int numBytesRead;
    numBytesRead=properFormatAudioInputStream.read(data);
    if (numBytesRead == -1) {
      return false;
    }
 else     if (numBytesRead != data.length) {
      return false;
    }
    double[] audioInDoubleArray;
    audioInDoubleArray=_byteArrayToDoubleArray(data,frameSizeInBytes);
    DoubleToken[] audioTokenArray=new DoubleToken[productionRate];
    for (i=0; i < productionRate; i++) {
      audioTokenArray[i]=new DoubleToken(audioInDoubleArray[i]);
    }
    output.sendArray(0,audioTokenArray);
    output.sendArray(1,audioTokenArray);
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(ex.getMessage());
  }
catch (  IOException ex) {
    throw new InternalErrorException(ex.getMessage());
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Output the sample value of the sound file corresponding to the current index.
 */
public boolean postfire() throws IllegalActionException {
  try {
    int i;
    int numBytesRead;
    numBytesRead=properFormatAudioInputStream.read(data);
    if (numBytesRead == -1) {
      audioTokenArray=new DoubleToken[productionRate];
      for (i=0; i < productionRate; i++) {
        audioTokenArray[i]=new DoubleToken(0);
      }
      output.sendArray(0,audioTokenArray);
      output.sendArray(1,audioTokenArray);
      return false;
    }
 else     if (numBytesRead != data.length) {
      audioTokenArray=new DoubleToken[productionRate];
      for (i=0; i < productionRate; i++) {
        audioTokenArray[i]=new DoubleToken(0);
      }
      output.sendArray(0,audioTokenArray);
      output.sendArray(1,audioTokenArray);
      return false;
    }
    audioInDoubleArray=_byteArrayToDoubleArray(data,frameSizeInBytes);
    audioTokenArray=new DoubleToken[productionRate];
    for (i=0; i < productionRate; i++) {
      audioTokenArray[i]=new DoubleToken(audioInDoubleArray[i]);
    }
    output.sendArray(0,audioTokenArray);
    output.sendArray(1,audioTokenArray);
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(ex.getMessage());
  }
catch (  IOException ex) {
    throw new InternalErrorException(ex.getMessage());
  }
  return true;
}
Program: 76313
Project: 76313
Buggy source:
/** 
 * Put an event into the event queue with the specified destination receiver, token, and depth.  The time stamp of the event is the current time, but the microstep is one larger than the current microstep.  This method is used by actors that declare that they introduce delay, but where the value of the delay is zero. This method must not be used before any firings have occurred (i.e. in the initialize() method) because current time has no meaning there.
 * @param receiver The destination receiver.
 * @param token The token destined for that receiver.
 * @param depth The depth.
 * @exception IllegalActionException If the delay is negative, or ifcurrent time has not been set.
 */
protected void _enqueueEvent(DEReceiver receiver,Token token,int depth) throws IllegalActionException {
  int microstep=0;
  if (_startTime == Double.MAX_VALUE) {
    Nameable destination=receiver.getContainer();
    throw new IllegalActionException(destination,"String_Node_Str" + "String_Node_Str");
  }
  _eventQueue.put(new DEEvent(receiver,token,getCurrentTime(),_microstep + 1,depth));
}

Fixed version (ground truth):
/** 
 * Put an event into the event queue with the specified destination receiver, token, and depth.  The time stamp of the event is the current time, but the microstep is one larger than the current microstep.  This method is used by actors that declare that they introduce delay, but where the value of the delay is zero. This method must not be used before any firings have occurred (i.e. in the initialize() method) because current time has no meaning there.
 * @param receiver The destination receiver.
 * @param token The token destined for that receiver.
 * @param depth The depth.
 * @exception IllegalActionException If the delay is negative, or ifcurrent time has not been set.
 */
protected void _enqueueEvent(DEReceiver receiver,Token token,int depth) throws IllegalActionException {
  if (_startTime == Double.MAX_VALUE) {
    Nameable destination=receiver.getContainer();
    throw new IllegalActionException(destination,"String_Node_Str" + "String_Node_Str");
  }
  _eventQueue.put(new DEEvent(receiver,token,getCurrentTime(),_microstep + 1,depth));
}
Program: 76315
Project: 76315
Buggy source:
public PtolemyQuery(){
  this.addQueryListener(this);
  _parameters=new HashMap();
}

Fixed version (ground truth):
/** 
 * Construct a panel with no queries in it.
 */
public PtolemyQuery(){
  super();
  this.addQueryListener(this);
  _parameters=new HashMap();
}
Program: 76316
Project: 76316
Buggy source:
/** 
 * After invoking super.init(), create and connect the actors.
 */
public void init(){
  super.init();
  add(_createRunControls(2));
  try {
    AudioSource soundSource=new AudioSource(_toplevel,"String_Node_Str");
    soundSource.pathName.setToken(new StringToken("String_Node_Str"));
    soundSource.isURL.setToken(new BooleanToken(false));
    AudioSink soundSink=new AudioSink(_toplevel,"String_Node_Str");
    soundSink.fileName.setToken(new StringToken("String_Node_Str"));
    int sampleRate=8000;
    soundSink.sampRate.setToken(new IntToken(sampleRate));
    _toplevel.connect(soundSource.output,soundSink.input);
  }
 catch (  Exception ex) {
    report("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
/** 
 * After invoking super.init(), create and connect the actors.
 */
public void init(){
  super.init();
  add(_createRunControls(2));
  try {
    AudioSource soundSource=new AudioSource(_toplevel,"String_Node_Str");
    soundSource.pathName.setToken(new StringToken("String_Node_Str"));
    soundSource.isURL.setToken(new BooleanToken(false));
    AudioSink soundSink=new AudioSink(_toplevel,"String_Node_Str");
    soundSink.fileName.setToken(new StringToken("String_Node_Str"));
    int sampleRate=44100;
    soundSink.sampRate.setToken(new IntToken(sampleRate));
    _toplevel.connect(soundSource.output,soundSink.input);
  }
 catch (  Exception ex) {
    report("String_Node_Str",ex);
  }
}
Program: 76317
Project: 76317
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public CodeBook(TypedCompositeActor container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  new Parameter(this,"String_Node_Str",new IntToken("String_Node_Str"));
  output=(TypedIOPort)newPort("String_Node_Str");
  output.setOutput(true);
  output.setTypeEquals(ObjectToken.class);
  input=(TypedIOPort)newPort("String_Node_Str");
  input.setInput(true);
  input.setTypeEquals(Token.class);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public CodeBook(TypedCompositeActor container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  new Parameter(this,"String_Node_Str",new IntToken("String_Node_Str"));
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setTypeEquals(Token.class);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(ObjectToken.class);
}
Program: 76319
Project: 76319
Buggy source:
/** 
 * Remove the count oldest objects from the queue and return them. If there is no such object in the queue (the queue is empty), throw an exception. If the history mechanism is enabled, then put the taken object in the history queue. If the capacity of the history queue would be exceeded by this, then first remove the oldest object in the history queue.
 * @return An array of objects from the queue.
 * @exception NoSuchElementException If the queue is empty.
 */
public void takeArray(Object obj[]) throws NoSuchElementException {
  int count=obj.length;
  if (size() < count) {
    String str="String_Node_Str";
    if (_container != null) {
      str="String_Node_Str" + _container.getFullName();
    }
    throw new NoSuchElementException("String_Node_Str" + str + "String_Node_Str");
  }
  if (count <= (_queuearray.length - _queueback)) {
    System.arraycopy(_queuearray,_queueback,obj,0,count);
  }
 else {
    System.arraycopy(_queuearray,_queueback,obj,0,_queuearray.length - _queueback);
    System.arraycopy(_queuearray,0,obj,_queuearray.length - _queueback,count - (_queuearray.length - _queueback));
  }
  _queueback+=count;
  if (_queueback >= _queuearray.length)   _queueback=_queueback % _queuearray.length;
  _queuesize-=count;
  if (_historycapacity != 0) {
    if (_historycapacity == _historylist.size()) {
      _historylist.take();
    }
    _historylist.insertLast(obj);
  }
}

Fixed version (ground truth):
/** 
 * Remove the count oldest objects from the queue and return them. If there is no such object in the queue (the queue is empty), throw an exception. If the history mechanism is enabled, then put the taken object in the history queue. If the capacity of the history queue would be exceeded by this, then first remove the oldest object in the history queue.
 * @return An array of objects from the queue.
 * @exception NoSuchElementException If the queue is empty.
 */
public void takeArray(Object obj[]) throws NoSuchElementException {
  int count=obj.length;
  if (size() < count) {
    String str="String_Node_Str";
    if (_container != null) {
      str="String_Node_Str" + _container.getFullName();
    }
    throw new NoSuchElementException("String_Node_Str" + str + "String_Node_Str");
  }
  if (count <= (_queueArray.length - _queueBack)) {
    System.arraycopy(_queueArray,_queueBack,obj,0,count);
  }
 else {
    System.arraycopy(_queueArray,_queueBack,obj,0,_queueArray.length - _queueBack);
    System.arraycopy(_queueArray,0,obj,_queueArray.length - _queueBack,count - (_queueArray.length - _queueBack));
  }
  _queueBack+=count;
  if (_queueBack >= _queueArray.length)   _queueBack=_queueBack % _queueArray.length;
  _queueSize-=count;
  if (_historyCapacity != 0) {
    if (_historyCapacity == _historyList.size()) {
      _historyList.removeFirst();
      ;
    }
    _historyList.addLast(obj);
  }
}
Program: 76320
Project: 76320
Buggy source:
/** 
 * Return the capacity of the history queue. This will be zero if the history mechanism is disabled and INFINITE_CAPACITY if the history capacity is infinite.
 * @return The capacity of the history queue.
 */
public int getHistoryCapacity(){
  return _historycapacity;
}

Fixed version (ground truth):
/** 
 * Return the capacity of the history queue. This will be zero if the history mechanism is disabled and INFINITE_CAPACITY if the history capacity is infinite.
 * @return The capacity of the history queue.
 */
public int getHistoryCapacity(){
  return _historyCapacity;
}
Program: 76321
Project: 76321
Buggy source:
/** 
 * Return true if the number of objects in the queue is zero
 * @return A boolean indicating whether the queue is empty.
 */
public boolean isEmpty(){
  return (_queuesize == 0);
}

Fixed version (ground truth):
/** 
 * Return true if the number of objects in the queue is zero
 * @return A boolean indicating whether the queue is empty.
 */
public boolean isEmpty(){
  return (_queueSize == 0);
}
Program: 76322
Project: 76322
Buggy source:
/** 
 * Enumerate the objects in the history, which are the N most recent objects taken from the queue, beginning with the oldest, where N is less than or equal to the history capacity. If the history capacity is infinite, then the enumeration includes all objects previously taken from the queue. If the history capacity is zero, then return an empty enumeration.
 * @return An enumeration of objects in the history.
 * @see collections.LinkedList#elements()
 */
public CollectionEnumeration historyElements(){
  return _historylist.elements();
}

Fixed version (ground truth):
/** 
 * Enumerate the objects in the history, which are the N most recent objects taken from the queue, beginning with the oldest, where N is less than or equal to the history capacity. If the history capacity is infinite, then the enumeration includes all objects previously taken from the queue. If the history capacity is zero, then return an empty enumeration.
 * @return An enumeration of objects in the history.
 * @see collections.LinkedList#elements()
 */
public Enumeration historyElements(){
  return Collections.enumeration(_historyList);
}
Program: 76323
Project: 76323
Buggy source:
/** 
 * Put an object 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 object to be put in the queue.
 * @return A boolean indicating success.
 */
public boolean put(Object element){
  if (_queuearray.length - _queuesize >= 1) {
    _queuearray[_queuefront++]=element;
    if (_queuefront >= _queuearray.length)     _queuefront=_queuefront % _queuearray.length;
    _queuesize++;
    return true;
  }
 else {
    if (_queuemaxcapacity == INFINITE_CAPACITY) {
      _resizeArray(_queuearray.length * 2);
      return put(element);
    }
 else     return false;
  }
}

Fixed version (ground truth):
/** 
 * Put an object 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 object to be put in the queue.
 * @return A boolean indicating success.
 */
public boolean put(Object element){
  if (_queueArray.length - _queueSize >= 1) {
    _queueArray[_queueFront++]=element;
    if (_queueFront >= _queueArray.length)     _queueFront=_queueFront % _queueArray.length;
    _queueSize++;
    return true;
  }
 else {
    if (_queueMaxCapacity == INFINITE_CAPACITY) {
      _resizeArray(_queueArray.length * 2);
      return put(element);
    }
 else     return false;
  }
}
Program: 76324
Project: 76324
Buggy source:
/** 
 * Return the number of objects in the history.
 * @return The current number of objects in the history.
 */
public int historySize(){
  return _historylist.size();
}

Fixed version (ground truth):
/** 
 * Return the number of objects in the history.
 * @return The current number of objects in the history.
 */
public int historySize(){
  return _historyList.size();
}
Program: 76325
Project: 76325
Buggy source:
/** 
 * Remove the oldest object from the queue and return it. If there is no such object in the queue (the queue is empty), throw an exception. If the history mechanism is enabled, then put the taken object in the history queue. If the capacity of the history queue would be exceeded by this, then first remove the oldest object in the history queue.
 * @return An object from the queue.
 * @exception NoSuchElementException If the queue is empty.
 */
public Object take() throws NoSuchElementException {
  Object obj=null;
  try {
    if (isEmpty())     throw new NoSuchElementException("String_Node_Str");
    obj=_queuearray[_queueback];
    _queuearray[_queueback]=null;
    _queueback++;
    if (_queueback >= _queuearray.length)     _queueback=_queueback % _queuearray.length;
    _queuesize--;
  }
 catch (  NoSuchElementException ex) {
    String str="String_Node_Str";
    if (_container != null) {
      str="String_Node_Str" + _container.getFullName();
    }
    throw new NoSuchElementException("String_Node_Str" + str + "String_Node_Str");
  }
  if (_historycapacity != 0) {
    if (_historycapacity == _historylist.size()) {
      _historylist.take();
    }
    _historylist.insertLast(obj);
  }
  return obj;
}

Fixed version (ground truth):
/** 
 * Remove the oldest object from the queue and return it. If there is no such object in the queue (the queue is empty), throw an exception. If the history mechanism is enabled, then put the taken object in the history queue. If the capacity of the history queue would be exceeded by this, then first remove the oldest object in the history queue.
 * @return An object from the queue.
 * @exception NoSuchElementException If the queue is empty.
 */
public Object take() throws NoSuchElementException {
  Object obj=null;
  try {
    if (isEmpty())     throw new NoSuchElementException("String_Node_Str");
    obj=_queueArray[_queueBack];
    _queueArray[_queueBack]=null;
    _queueBack++;
    if (_queueBack >= _queueArray.length)     _queueBack=_queueBack % _queueArray.length;
    _queueSize--;
  }
 catch (  NoSuchElementException ex) {
    String str="String_Node_Str";
    if (_container != null) {
      str="String_Node_Str" + _container.getFullName();
    }
    throw new NoSuchElementException("String_Node_Str" + str + "String_Node_Str");
  }
  if (_historyCapacity != 0) {
    if (_historyCapacity == _historyList.size()) {
      _historyList.removeFirst();
      ;
    }
    _historyList.addLast(obj);
  }
  return obj;
}
Program: 76326
Project: 76326
Buggy source:
/** 
 * Copy constructor. Create a copy of the specified queue, but with no container. This is useful to permit enumerations over a queue while the queue continues to be modified. The objects in the queue themselves are not cloned.
 * @param model The queue to be copied.
 */
public ArrayFIFOQueue(ArrayFIFOQueue model){
  this();
synchronized (model) {
    _queuesize=model._queuesize;
    _queuearray=new Object[model._queuearray.length];
    _queuefront=model._queuefront;
    _queueback=model._queueback;
    System.arraycopy(model._queuearray,0,_queuearray,0,_queuearray.length);
    _historylist.appendElements(model.historyElements());
  }
}

Fixed version (ground truth):
/** 
 * Copy constructor. Create a copy of the specified queue, but with no container. This is useful to permit enumerations over a queue while the queue continues to be modified. The objects in the queue themselves are not cloned.
 * @param model The queue to be copied.
 */
public ArrayFIFOQueue(ArrayFIFOQueue model){
  this();
synchronized (model) {
    _queueSize=model._queueSize;
    _queueArray=new Object[model._queueArray.length];
    _queueFront=model._queueFront;
    _queueBack=model._queueBack;
    System.arraycopy(model._queueArray,0,_queueArray,0,_queueArray.length);
    _historyList.addAll(model._historyList);
  }
}
Program: 76327
Project: 76327
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 any of 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 putArray(Object element[]){
  if (_queuearray.length - _queuesize >= element.length) {
    int i;
    if (element.length <= (_queuearray.length - _queuefront)) {
      System.arraycopy(element,0,_queuearray,_queuefront,element.length);
      _queuefront+=element.length;
      if (_queuefront >= _queuearray.length)       _queuefront=_queuefront % _queuearray.length;
      _queuesize+=element.length;
    }
 else {
      System.arraycopy(element,0,_queuearray,_queuefront,_queuearray.length - _queuefront);
      System.arraycopy(element,_queuearray.length - _queuefront,_queuearray,0,element.length - (_queuearray.length - _queuefront));
      _queuefront+=element.length;
      if (_queuefront >= _queuearray.length)       _queuefront=_queuefront % _queuearray.length;
      _queuesize+=element.length;
    }
    return true;
  }
 else {
    if (_queuemaxcapacity == INFINITE_CAPACITY) {
      try {
        _resizeArray(_queuearray.length * 2);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      return putArray(element);
    }
 else     return false;
  }
}

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 any of 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 putArray(Object element[]){
  if (_queueArray.length - _queueSize >= element.length) {
    int i;
    if (element.length <= (_queueArray.length - _queueFront)) {
      System.arraycopy(element,0,_queueArray,_queueFront,element.length);
      _queueFront+=element.length;
      if (_queueFront >= _queueArray.length)       _queueFront=_queueFront % _queueArray.length;
      _queueSize+=element.length;
    }
 else {
      System.arraycopy(element,0,_queueArray,_queueFront,_queueArray.length - _queueFront);
      System.arraycopy(element,_queueArray.length - _queueFront,_queueArray,0,element.length - (_queueArray.length - _queueFront));
      _queueFront+=element.length;
      if (_queueFront >= _queueArray.length)       _queueFront=_queueFront % _queueArray.length;
      _queueSize+=element.length;
    }
    return true;
  }
 else {
    if (_queueMaxCapacity == INFINITE_CAPACITY) {
      try {
        _resizeArray(_queueArray.length * 2);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      return putArray(element);
    }
 else     return false;
  }
}
Program: 76328
Project: 76328
Buggy source:
/** 
 * Return the number of objects in the queue.
 * @return The number of objects in the queue.
 */
public int size(){
  return _queuesize;
}

Fixed version (ground truth):
/** 
 * Return the number of objects in the queue.
 * @return The number of objects in the queue.
 */
public int size(){
  return _queueSize;
}
Program: 76329
Project: 76329
Buggy source:
/** 
 * Resize the internal circular array to have the given size.
 * @exception InternalErrorException If the proposed size is greater thanthe declared maximum size, or if the queue contains more objects than the proposed size or the proposed size is illegal. .
 */
private void _resizeArray(int newsize){
  if (newsize < 0) {
    throw new InternalErrorException("String_Node_Str" + newsize + "String_Node_Str");
  }
  if (size() > newsize) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  if ((_queuemaxcapacity != INFINITE_CAPACITY) && (newsize > _queuemaxcapacity)) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  Object newarray[]=new Object[newsize];
  if ((_queuefront < _queueback) || isFull()) {
    System.arraycopy(_queuearray,_queueback,newarray,0,_queuearray.length - _queueback);
    System.arraycopy(_queuearray,0,newarray,_queuearray.length - _queueback,_queuefront);
    _queuefront=_queuearray.length - _queueback + _queuefront;
  }
 else {
    System.arraycopy(_queuearray,_queueback,newarray,0,_queuefront - _queueback);
    _queuefront=_queuefront - _queueback;
  }
  _queuearray=newarray;
  _queueback=0;
}

Fixed version (ground truth):
/** 
 * Resize the internal circular array to have the given size.
 * @exception InternalErrorException If the proposed size is greater thanthe declared maximum size, or if the queue contains more objects than the proposed size or the proposed size is illegal. .
 */
private void _resizeArray(int newsize){
  if (newsize < 0) {
    throw new InternalErrorException("String_Node_Str" + newsize + "String_Node_Str");
  }
  if (size() > newsize) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  if ((_queueMaxCapacity != INFINITE_CAPACITY) && (newsize > _queueMaxCapacity)) {
    throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
  }
  Object newarray[]=new Object[newsize];
  if ((_queueFront < _queueBack) || isFull()) {
    System.arraycopy(_queueArray,_queueBack,newarray,0,_queueArray.length - _queueBack);
    System.arraycopy(_queueArray,0,newarray,_queueArray.length - _queueBack,_queueFront);
    _queueFront=_queueArray.length - _queueBack + _queueFront;
  }
 else {
    System.arraycopy(_queueArray,_queueBack,newarray,0,_queueFront - _queueBack);
    _queueFront=_queueFront - _queueBack;
  }
  _queueArray=newarray;
  _queueBack=0;
}
Program: 76330
Project: 76330
Buggy source:
/** 
 * Enumerate the objects in the queue, beginning with the oldest.
 * @return An enumeration of objects.
 * @see collections.LinkedList#elements()
 */
public CollectionEnumeration elements(){
  LinkedList l=new LinkedList();
  int i;
  if ((_queuefront < _queueback) || isFull()) {
    for (i=_queueback; (i < _queuearray.length); i++)     l.insertLast(_queuearray[i]);
    for (i=0; (i < _queuefront); i++)     l.insertLast(_queuearray[i]);
  }
 else   for (i=_queueback; (i < _queuefront); i++)   l.insertLast(_queuearray[i]);
  return l.elements();
}

Fixed version (ground truth):
/** 
 * Enumerate the objects in the queue, beginning with the oldest.
 * @return An enumeration of objects.
 * @see collections.LinkedList#elements()
 */
public Enumeration elements(){
  return Collections.enumeration(elementList());
}
Program: 76332
Project: 76332
Buggy source:
/** 
 * Return true if the number of objects in the queue equals the queue capacity.
 * @return A boolean indicating whether the queue is full.
 */
public boolean isFull(){
  return (_queuesize >= _queuearray.length);
}

Fixed version (ground truth):
/** 
 * Return true if the number of objects in the queue equals the queue capacity.
 * @return A boolean indicating whether the queue is full.
 */
public boolean isFull(){
  return (_queueSize >= _queueArray.length);
}
Program: 76333
Project: 76333
Buggy source:
/** 
 * Set queue capacity. Use INFINITE_CAPACITY to indicate unbounded capacity (which is the default). If the current size of the queue exceeds the desired capacity, throw an exception.
 * @param capacity The desired capacity.
 * @exception IllegalActionException If the queue contains moreobjects than the proposed capacity or the proposed capacity is illegal.
 */
public void setCapacity(int capacity) throws IllegalActionException {
  if (capacity == INFINITE_CAPACITY) {
    _queuemaxcapacity=INFINITE_CAPACITY;
    return;
  }
  if (capacity < -1) {
    throw new IllegalActionException(_container,"String_Node_Str");
  }
  if (size() > capacity) {
    throw new IllegalActionException(_container,"String_Node_Str" + "String_Node_Str");
  }
  _queuemaxcapacity=capacity;
  _resizeArray(capacity);
}

Fixed version (ground truth):
/** 
 * Set queue capacity. Use INFINITE_CAPACITY to indicate unbounded capacity (which is the default). If the current size of the queue exceeds the desired capacity, throw an exception.
 * @param capacity The desired capacity.
 * @exception IllegalActionException If the queue contains moreobjects than the proposed capacity or the proposed capacity is illegal.
 */
public void setCapacity(int capacity) throws IllegalActionException {
  if (capacity == INFINITE_CAPACITY) {
    _queueMaxCapacity=INFINITE_CAPACITY;
    return;
  }
  if (capacity < -1) {
    throw new IllegalActionException(_container,"String_Node_Str");
  }
  if (size() > capacity) {
    throw new IllegalActionException(_container,"String_Node_Str" + "String_Node_Str");
  }
  _queueMaxCapacity=capacity;
  _resizeArray(capacity);
}
Program: 76334
Project: 76334
Buggy source:
/** 
 * Return the queue capacity This will INFINITE_CAPACITY if the capacity is infinite.
 * @return The capacity of the queue.
 */
public int getCapacity(){
  return _queuemaxcapacity;
}

Fixed version (ground truth):
/** 
 * Return the queue capacity This will be INFINITE_CAPACITY if the capacity is infinite.
 * @return The capacity of the queue.
 */
public int getCapacity(){
  return _queueMaxCapacity;
}
Program: 76335
Project: 76335
Buggy source:
/** 
 * Set the capacity of the history queue. Use 0 to disable the history mechanism and INFINITE_CAPACITY to make the history capacity unbounded. If the size of the history queue exceeds the desired capacity, remove the oldest objects from the history queue until its size equals the proposed capacity. Note that this can be used to clear the history queue by supplying 0 as the argument.
 * @param capacity The desired capacity of the history queue.
 * @exception IllegalActionException If the desired capacityis illegal.
 */
public void setHistoryCapacity(int capacity) throws IllegalActionException {
  if (capacity > 0) {
    while (_historylist.size() > capacity) {
      _historylist.take();
    }
  }
 else   if (capacity == 0) {
    _historylist.clear();
  }
 else   if (capacity != INFINITE_CAPACITY) {
    throw new IllegalActionException(_container,"String_Node_Str" + capacity);
  }
  _historycapacity=capacity;
}

Fixed version (ground truth):
/** 
 * Set the capacity of the history queue. Use 0 to disable the history mechanism and INFINITE_CAPACITY to make the history capacity unbounded. If the size of the history queue exceeds the desired capacity, remove the oldest objects from the history queue until its size equals the proposed capacity. Note that this can be used to clear the history queue by supplying 0 as the argument.
 * @param capacity The desired capacity of the history queue.
 * @exception IllegalActionException If the desired capacityis illegal.
 */
public void setHistoryCapacity(int capacity) throws IllegalActionException {
  if (capacity > 0) {
    while (_historyList.size() > capacity) {
      _historyList.removeFirst();
      ;
    }
  }
 else   if (capacity == 0) {
    _historyList.clear();
  }
 else   if (capacity != INFINITE_CAPACITY) {
    throw new IllegalActionException(_container,"String_Node_Str" + capacity);
  }
  _historyCapacity=capacity;
}
Program: 76336
Project: 76336
Buggy source:
/** 
 * Set the firing vector, which is a LLMap associating an Actor with the number of times that it will fire during an SDF iteration. Every object that this Scheduler is responsible for should have an entry, even if it is zero indicating that the Actor has not yet had its firings determined.
 * @param newfiringvector A LLMap from ComponentEntity to Integer.
 */
private void _setFiringVector(LLMap newfiringvector){
  _firingvector=newfiringvector;
  _firingvectorvalid=true;
}

Fixed version (ground truth):
/** 
 * Set the firing vector, which is a Map associating an Actor with the number of times that it will fire during an SDF iteration. Every object that this Scheduler is responsible for should have an entry, even if it is zero indicating that the Actor has not yet had its firings determined.
 * @param newfiringvector A Map from ComponentEntity to Integer.
 */
private void _setFiringVector(Map newfiringvector){
  _firingvector=newfiringvector;
  _firingvectorvalid=true;
}
Program: 76340
Project: 76340
Buggy source:
/** 
 * Set the number of firings associated with the Actor.   This is equivalent to changing the entry in the FiringVector associated with with the entity to have a value count.
 */
private void _setFiringCount(Entity entity,int count){
  _firingvector=(LLMap)_firingvector.puttingAt(entity,new Integer(count));
}

Fixed version (ground truth):
/** 
 * Set the number of firings associated with the Actor.   This is equivalent to changing the entry in the FiringVector associated with with the entity to have a value count.
 */
private void _setFiringCount(Entity entity,int count){
  _firingvector.put(entity,new Integer(count));
}
Program: 76341
Project: 76341
Buggy source:
/** 
 * Normalize fractional firing ratios into a firing vector that corresponds to a single SDF iteration.   Multiply all of the fractions by the GCD of their denominators.
 * @param Firings LLMap of firing ratios to be normalized
 * @return The normalized firing vector.
 * @exception InternalErrorException If the calculated GCD does notnormalize all of the fractions.
 */
private LLMap _normalizeFirings(LLMap firings){
  Enumeration unnormalizedFirings=firings.elements();
  int lcm=1;
  _debug("String_Node_Str");
  while (unnormalizedFirings.hasMoreElements()) {
    Fraction f=(Fraction)unnormalizedFirings.nextElement();
    int den=f.getDenominator();
    lcm=Fraction.lcm(lcm,den);
  }
  _debug("String_Node_Str" + (new Integer(lcm)).toString());
  Enumeration Actors=firings.keys();
  Fraction lcmFraction=new Fraction(lcm);
  while (Actors.hasMoreElements()) {
    Object actor=Actors.nextElement();
    _debug("String_Node_Str" + ((ComponentEntity)actor).getName());
    Fraction reps=(Fraction)firings.at(actor);
    reps=reps.multiply(lcmFraction);
    if (reps.getDenominator() != 1)     throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
    firings=(LLMap)firings.puttingAt(actor,new Integer(reps.getNumerator()));
  }
  return firings;
}

Fixed version (ground truth):
/** 
 * Normalize fractional firing ratios into a firing vector that corresponds to a single SDF iteration.   Multiply all of the fractions by the GCD of their denominators.
 * @param Firings Map of firing ratios to be normalized
 * @exception InternalErrorException If the calculated GCD does notnormalize all of the fractions.
 */
private void _normalizeFirings(Map firings){
  Iterator unnormalizedFirings=firings.values().iterator();
  int lcm=1;
  _debug("String_Node_Str");
  while (unnormalizedFirings.hasNext()) {
    Fraction f=(Fraction)unnormalizedFirings.next();
    int den=f.getDenominator();
    lcm=Fraction.lcm(lcm,den);
  }
  _debug("String_Node_Str" + (new Integer(lcm)).toString());
  Iterator Actors=firings.keySet().iterator();
  Fraction lcmFraction=new Fraction(lcm);
  while (Actors.hasNext()) {
    Object actor=Actors.next();
    _debug("String_Node_Str" + ((ComponentEntity)actor).getName());
    Fraction reps=(Fraction)firings.get(actor);
    reps=reps.multiply(lcmFraction);
    if (reps.getDenominator() != 1)     throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
    firings.put(actor,new Integer(reps.getNumerator()));
  }
}
Program: 76342
Project: 76342
Buggy source:
/** 
 * Initialize the local data members of this object.  
 */
protected void _localMemberInitialize(){
  LLMap _firingvector=new LLMap();
  _firingvectorvalid=true;
}

Fixed version (ground truth):
/** 
 * Initialize the local data members of this object.  
 */
protected void _localMemberInitialize(){
  _firingvector=new TreeMap(new NamedObjComparator());
  _firingvectorvalid=true;
}
Program: 76343
Project: 76343
Buggy source:
/** 
 * Return the number of firings associated with the Actor.   This is equivalent to indexing into the Map returned by _getFiringVector and casting the result to an integer.
 */
private int _getFiringCount(Entity entity){
  _debug(_firingvector.toString());
  return ((Integer)_firingvector.at(entity)).intValue();
}

Fixed version (ground truth):
/** 
 * Return the number of firings associated with the Actor.   This is equivalent to indexing into the Map returned by _getFiringVector and casting the result to an integer.
 */
private int _getFiringCount(Entity entity){
  return ((Integer)_firingvector.get(entity)).intValue();
}
Program: 76347
Project: 76347
Buggy source:
/** 
 * Return the firing vector, which is a LLMap associating an Actor with the number of times that it will fire during an SDF iteration. The firing vector is only guaranteed to be valid if the schedule is valid.
 * @return A LLMap from ComponentEntity to Integer.
 */
private LLMap _getFiringVector(){
  return _firingvector;
}

Fixed version (ground truth):
/** 
 * Return the firing vector, which is a Map associating an Actor with the number of times that it will fire during an SDF iteration. The firing vector is only guaranteed to be valid if the schedule is valid.
 * @return A Map from ComponentEntity to Integer.
 */
private Map _getFiringVector(){
  return _firingvector;
}
Program: 76348
Project: 76348
Buggy source:
/** 
 * Simulate the consumption of tokens by the actor during an execution. The entries in LLMap will be modified to reflect the number of tokens still waiting after the actor has consumed tokens for a firing. Also determine if enough tokens still remain at the inputs of the actor for it to fire again immediately.
 * @param currentActor The actor that is being simulated.
 * @param waitingTokens A Map between each input IOPort and the number oftokens in the queue for that port.
 * @return boolean Whether or not the actor can fire again right awayafter it has consumed tokens.
 * @exception IllegalActionException if any called method throws it.
 */
private boolean _simulateInputConsumption(ComponentEntity currentActor,LLMap waitingTokens) throws IllegalActionException {
  boolean stillReadyToSchedule=true;
  Enumeration inputPorts=((Actor)currentActor).inputPorts();
  while (inputPorts.hasMoreElements()) {
    IOPort inputPort=(IOPort)inputPorts.nextElement();
    int[] tokens=(int[])waitingTokens.at(inputPort);
    int tokenrate=_getTokenConsumptionRate(inputPort);
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      tokens[channel]-=tokenrate;
      if (tokens[channel] < tokenrate)       stillReadyToSchedule=false;
    }
  }
  return stillReadyToSchedule;
}

Fixed version (ground truth):
/** 
 * Simulate the consumption of tokens by the actor during an execution. The entries in Map will be modified to reflect the number of tokens still waiting after the actor has consumed tokens for a firing. Also determine if enough tokens still remain at the inputs of the actor for it to fire again immediately.
 * @param currentActor The actor that is being simulated.
 * @param waitingTokens A Map between each input IOPort and the number oftokens in the queue for that port.
 * @return boolean Whether or not the actor can fire again right awayafter it has consumed tokens.
 * @exception IllegalActionException if any called method throws it.
 */
private boolean _simulateInputConsumption(ComponentEntity currentActor,Map waitingTokens) throws IllegalActionException {
  boolean stillReadyToSchedule=true;
  Enumeration inputPorts=((Actor)currentActor).inputPorts();
  while (inputPorts.hasMoreElements()) {
    IOPort inputPort=(IOPort)inputPorts.nextElement();
    int[] tokens=(int[])waitingTokens.get(inputPort);
    int tokenrate=_getTokenConsumptionRate(inputPort);
    for (int channel=0; channel < inputPort.getWidth(); channel++) {
      tokens[channel]-=tokenrate;
      if (tokens[channel] < tokenrate)       stillReadyToSchedule=false;
    }
  }
  return stillReadyToSchedule;
}
Program: 76352
Project: 76352
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 {
  Nameable destination=receiver.getContainer();
  if (time < getCurrentTime()) {
    throw new IllegalActionException(destination,"String_Node_Str");
  }
  DEEventTag key=new DEEventTag(time,depth);
  DEEvent event=new DEEvent(receiver,token,key);
  _eventQueue.put(event);
  _debug("String_Node_Str",destination.getFullName(),"String_Node_Str" + time,"String_Node_Str" + depth);
}

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 {
  Nameable destination=receiver.getContainer();
  if (time < getCurrentTime()) {
    throw new IllegalActionException(destination,"String_Node_Str");
  }
  DEEventTag key=new DEEventTag(time,depth);
  DEEvent event=new DEEvent(receiver,token,key);
  _eventQueue.put(event);
}
Program: 76354
Project: 76354
Buggy source:
/** 
 * If the topological sort is not valid, then compute it.
 * @return True.
 * @exception IllegalActionException If the graph has a zerodelay loop.
 */
public boolean prefire() throws IllegalActionException {
  if (!_sortValid) {
    _computeDepth();
  }
  return super.prefire();
}

Fixed version (ground truth):
/** 
 * If the topological sort is not valid, then compute it.
 * @return True.
 * @exception IllegalActionException If the graph has a zerodelay loop.
 */
public boolean prefire() throws IllegalActionException {
  if (!_sortValid) {
    _computeDepth();
    _sortValid=true;
  }
  return super.prefire();
}