nus-yam/ex-repair huggingface dataset:
Program: 75239
Project: 75239
Buggy source:
/** 
 * If there is an input token, read it to begin servicing it. Note that service actually begins in the postfire() method, which will produce the token that is read on the output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  delay.update();
  _delay=((DoubleToken)delay.getToken()).doubleValue();
  Time currentTime=getDirector().getModelTime();
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
    _delayedTokensList.addLast(_currentInput);
  }
 else {
    _currentInput=null;
  }
  if (currentTime.compareTo(_nextTimeFree) == 0) {
    _currentOutput=(Token)_delayedTokens.get(new Double(currentTime.getDoubleValue()));
    if (_currentOutput == null) {
      throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
    }
    output.send(0,_currentOutput);
  }
}

Fixed version (ground truth):
/** 
 * Read the available input token. If the server is not busy,  begin servicing it. If the delay is 0, output is immediately availabe. Otherwise, the output available time is delayed by the amount of the  <i>newServiceTime></i> parameter. If the server is busy, check whether the current service finishes. If so, generate output. Otherwise, do nothing. 
 * @exception IllegalActionException If can not update the serviceTimeparameter, read inputs, or send outputs.
 */
public void fire() throws IllegalActionException {
  delay.update();
  _delay=((DoubleToken)delay.getToken()).doubleValue();
  Time currentTime=getDirector().getModelTime();
  if (input.hasToken(0)) {
    _currentInput=input.get(0);
    _delayedInputTokensList.addLast(_currentInput);
  }
 else {
    _currentInput=null;
  }
  if (_delayedTokens.size() > 0) {
    if (currentTime.compareTo(_nextTimeFree) == 0) {
      _currentOutput=(Token)_delayedTokens.get(currentTime);
      if (_currentOutput == null) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
      }
      output.send(0,_currentOutput);
    }
 else {
    }
  }
 else {
    if (_delay == 0 && _delayedInputTokensList.size() > 0) {
      output.send(0,(Token)_delayedInputTokensList.removeFirst());
    }
  }
}
Program: 75240
Project: 75240
Buggy source:
/** 
 * Indicate that the server is not busy.
 * @exception IllegalActionException If the base class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _nextTimeFree=Time.NEGATIVE_INFINITY;
  _delayedTokensList=new LinkedList();
}

Fixed version (ground truth):
/** 
 * Reset the states of the server to indicate that the server is ready to serve.
 * @exception IllegalActionException If the base class throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _nextTimeFree=Time.NEGATIVE_INFINITY;
  _delayedInputTokensList=new LinkedList();
}
Program: 75241
Project: 75241
Buggy source:
/** 
 * Set up the production constant.
 * @exception IllegalActionException If the length of the table is nota power of two.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  _wordLength=((IntToken)(wordLength.getToken())).intValue();
  _outputRate.setToken(new IntToken(_wordLength));
  ArrayToken tableToken=(ArrayToken)table.getToken();
  _size=1 << _wordLength;
  if (tableToken.length() < _size) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + _size + "String_Node_Str"+ tableToken.length());
  }
  _table=new Complex[_size];
  for (int i=0; i < _size; i++)   _table[i]=((ComplexToken)tableToken.getElement(i)).complexValue();
}

Fixed version (ground truth):
/** 
 * Set up the production constant.
 * @exception IllegalActionException If the length of the table is nota power of two.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
  _wordLength=((IntToken)(wordLength.getToken())).intValue();
  _outputRate.setToken(new IntToken(_wordLength));
  ArrayToken tableToken=(ArrayToken)table.getToken();
  _size=1 << _wordLength;
  if (tableToken.length() < _size) {
    _size=tableToken.length();
  }
  _table=new Complex[_size];
  for (int i=0; i < _size; i++)   _table[i]=((ComplexToken)tableToken.getElement(i)).complexValue();
}
Program: 75242
Project: 75242
Buggy source:
/** 
 * Return false if any input channel does not have a token. Otherwise, return whatever the superclass returns.
 * @return False if there are not enough tokens to fire.
 * @exception IllegalActionException If there is no director.
 */
public boolean prefire() throws IllegalActionException {
  if (control.hasToken(0)) {
    _control=((BooleanToken)control.get(0)).booleanValue();
  }
  if (_control) {
    if (!trueInput.hasToken(0)) {
      return false;
    }
  }
 else {
    if (!falseInput.hasToken(0)) {
      return false;
    }
  }
  return super.prefire();
}

Fixed version (ground truth):
/** 
 * Return false if any input channel does not have a token. Otherwise, return whatever the superclass returns.
 * @return False if there are not enough tokens to fire.
 * @exception IllegalActionException If there is no director.
 */
public boolean prefire() throws IllegalActionException {
  if (control.hasToken(0)) {
    _control=((BooleanToken)control.get(0)).booleanValue();
    if (_control) {
      if (!trueInput.hasToken(0)) {
        return false;
      }
    }
 else {
      if (!falseInput.hasToken(0)) {
        return false;
      }
    }
  }
 else {
    return false;
  }
  return super.prefire();
}
Program: 75243
Project: 75243
Buggy source:
private void _fireExactlyOneIteration() throws IllegalActionException {
  if (_debugging && _verbose)   _debug("String_Node_Str" + getModelTime(),"String_Node_Str" + getCurrentStepSize());
  ODESolver solver=getCurrentODESolver();
  if (_debugging && _verbose)   _debug("String_Node_Str" + solver.getName());
  prefireClear();
  _prefireDynamicActors();
  solver.fireStateTransitionActors();
  solver.fireDynamicActors();
  produceOutput();
  updateContinuousStates();
  setSuggestedNextStepSize(_predictNextStepSize());
}

Fixed version (ground truth):
private void _fireExactlyOneIteration() throws IllegalActionException {
  if (_debugging && _verbose)   _debug("String_Node_Str" + getModelTime(),"String_Node_Str" + getCurrentStepSize());
  ODESolver solver=getCurrentODESolver();
  if (_debugging && _verbose)   _debug("String_Node_Str" + solver.getName());
  prefireClear();
  _setExecutionPhase(CTExecutionPhase.PREFIRINGDYNAMICACTORS_PHASE);
  _prefireDynamicActors();
  _setExecutionPhase(CTExecutionPhase.UNKNOWN_PHASE);
  _setExecutionPhase(CTExecutionPhase.FIRINGSTATETRANSITIONACTORS_PHASE);
  solver.fireStateTransitionActors();
  _setExecutionPhase(CTExecutionPhase.UNKNOWN_PHASE);
  _setExecutionPhase(CTExecutionPhase.FIRINGDYNAMICACTORS_PHASE);
  solver.fireDynamicActors();
  _setExecutionPhase(CTExecutionPhase.UNKNOWN_PHASE);
  _setExecutionPhase(CTExecutionPhase.PRODUCINGOUTPUTS_PHASE);
  produceOutput();
  _setExecutionPhase(CTExecutionPhase.UNKNOWN_PHASE);
  _setExecutionPhase(CTExecutionPhase.UPDATINGCONTINUOUSSTATES_PHASE);
  updateContinuousStates();
  _setExecutionPhase(CTExecutionPhase.UNKNOWN_PHASE);
  setSuggestedNextStepSize(_predictNextStepSize());
}
Program: 75245
Project: 75245
Buggy source:
/** 
 * Return true if there is an event at current time.
 * @return True if there is an event at current time.
 */
public boolean hasCurrentEvent(){
  try {
    CTSchedule schedule=(CTSchedule)getScheduler().getSchedule();
    Iterator eventGenerators=schedule.get(CTSchedule.EVENT_GENERATORS).actorIterator();
    boolean hasDiscreteEvents=false;
    while (eventGenerators.hasNext()) {
      CTEventGenerator generator=(CTEventGenerator)eventGenerators.next();
      if (generator.hasCurrentEvent()) {
        hasDiscreteEvents=true;
      }
    }
    if (hasDiscreteEvents)     return true;
    if (getBreakPoints().contains(getModelTime())) {
      if (_debugging) {
        _debug("String_Node_Str" + getBreakPoints().first());
      }
      hasDiscreteEvents=true;
    }
    return hasDiscreteEvents;
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Return true if there is an event at current time.
 * @return True if there is an event at current time.
 */
public boolean hasCurrentEvent(){
  try {
    CTSchedule schedule=(CTSchedule)getScheduler().getSchedule();
    Iterator eventGenerators=schedule.get(CTSchedule.EVENT_GENERATORS).actorIterator();
    boolean hasDiscreteEvents=false;
    while (eventGenerators.hasNext()) {
      CTEventGenerator generator=(CTEventGenerator)eventGenerators.next();
      if (generator.hasCurrentEvent()) {
        hasDiscreteEvents=true;
      }
    }
    hasDiscreteEvents|=_processBreakpoints();
    return hasDiscreteEvents;
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
}
Program: 75247
Project: 75247
Buggy source:
/** 
 * Return true if this director is embedded inside an opaque composite actor contained by another composite actor.
 */
protected boolean _isEmbedded(){
  return (getContainer() != null && getContainer().getContainer() != null);
}

Fixed version (ground truth):
/** 
 * Return true if this director is embedded inside an opaque composite actor contained by another composite actor.
 */
protected boolean _isEmbedded(){
  return !_isTopLevel();
}
Program: 75248
Project: 75248
Buggy source:
/** 
 * Return true if this is a top-level director. Parts of this method is read synchronized on the workspace.
 * @return True if this director is at the top-level.
 */
protected boolean _isTopLevel(){
  CompositeActor container=(CompositeActor)getContainer();
  if (container.getExecutiveDirector() == null) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Return true if this is a top-level director. Parts of this method is read synchronized on the workspace.
 * @return True if this director is at the top-level.
 */
protected boolean _isTopLevel(){
  NamedObj container=getContainer();
  if (container instanceof CompositeActor) {
    if (((CompositeActor)container).getExecutiveDirector() == null) {
      return true;
    }
 else {
      return false;
    }
  }
  return true;
}
Program: 75249
Project: 75249
Buggy source:
/** 
 * If the container of this director does not have an HDFFSMDirector as its executive director, then return it. Otherwise, move up the hierarchy until we reach a container actor that does not have an HDFFSMDirector director for its executive director.
 * @exception IllegalActionException If the top-level directoris an HDFFSMDirector.
 */
private CompositeActor _getHighestFSM() throws IllegalActionException {
  CompositeActor container=(CompositeActor)getContainer();
  Director director=container.getExecutiveDirector();
  boolean foundValidDirector=false;
  while (foundValidDirector == false) {
    if (director == null) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
 else     if (director instanceof HDFDirector) {
      foundValidDirector=true;
    }
 else     if (director instanceof SDFDirector || director instanceof DDFDirector) {
      foundValidDirector=true;
      _embeddedInSDF=true;
    }
 else {
      container=(CompositeActor)(container.getContainer());
      director=container.getExecutiveDirector();
    }
  }
  return container;
}

Fixed version (ground truth):
/** 
 * If the container of this director does not have an HDFFSMDirector as its executive director, then return it. Otherwise, move up the hierarchy until we reach a container actor that does not have an HDFFSMDirector director for its executive director.
 * @exception IllegalActionException If the top-level directoris an HDFFSMDirector.
 */
private CompositeActor _getHighestFSM() throws IllegalActionException {
  CompositeActor container=(CompositeActor)getContainer();
  Director director=container.getExecutiveDirector();
  boolean foundValidDirector=false;
  while (foundValidDirector == false) {
    if (director == null) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
 else     if (director instanceof HDFDirector) {
      foundValidDirector=true;
    }
 else     if (director instanceof SDFDirector || director instanceof DDFDirector || director instanceof GiottoDirector) {
      foundValidDirector=true;
      _embeddedInSDF=true;
    }
 else {
      container=(CompositeActor)(container.getContainer());
      director=container.getExecutiveDirector();
    }
  }
  return container;
}
Program: 75251
Project: 75251
Buggy source:
/** 
 * Given a double value, return a new double with precision as  given.
 * @param value The double value.
 * @param precision The precision.
 * @return A double value with the given precision.
 */
public static double round(double value,double precision){
  precision=-Math.log(precision) / Math.log(10);
  value=Math.round(value * Math.pow(10,precision)) / Math.pow(10,precision);
  return value;
}

Fixed version (ground truth):
/** 
 * Given a double value, return a new double with precision as  given.
 * @param value The double value.
 * @param precision The precision.
 * @return A double value with the given precision.
 */
public static double round(double value,double precision){
  long numberOfDigits=-Math.round((float)Math.log(precision) / Math.log(10));
  double newValue=Math.round(value * Math.pow(10,numberOfDigits)) / Math.pow(10,numberOfDigits);
  return newValue;
}
Program: 75253
Project: 75253
Buggy source:
/** 
 * Move the specified element to the specified position in the list. If the specified element is not in the list, then throw an exception.
 * @param element Element to move.
 * @param index The position to which to move it.
 * @return The index of the specified object prior to moving it,or -1 if it was not moved (it is already at the specified position).
 * @exception IllegalActionException If the argument is noton the list, or if the specified position is out of range.
 */
public int moveToIndex(Nameable element,int index) throws IllegalActionException {
  int priorIndex=_namedList.indexOf(element);
  if (priorIndex < 0) {
    throw new IllegalActionException(element,"String_Node_Str");
  }
 else   if (index < 0 || index >= _namedList.size()) {
    throw new IllegalActionException(element,"String_Node_Str");
  }
 else   if (priorIndex != index) {
    _namedList.remove(element);
    _namedList.add(index,element);
    return index;
  }
 else {
    return -1;
  }
}

Fixed version (ground truth):
/** 
 * Move the specified element to the specified position in the list. If the specified element is not in the list, then throw an exception.
 * @param element Element to move.
 * @param index The position to which to move it.
 * @return The index of the specified object prior to moving it,or -1 if it was not moved (it is already at the specified position).
 * @exception IllegalActionException If the argument is noton the list, or if the specified position is out of range.
 */
public int moveToIndex(Nameable element,int index) throws IllegalActionException {
  int priorIndex=_namedList.indexOf(element);
  if (priorIndex < 0) {
    throw new IllegalActionException(element,"String_Node_Str");
  }
 else   if (index < 0 || index >= _namedList.size()) {
    throw new IllegalActionException(element,"String_Node_Str");
  }
 else   if (priorIndex != index) {
    _namedList.remove(element);
    _namedList.add(index,element);
    return priorIndex;
  }
 else {
    return -1;
  }
}
Program: 75254
Project: 75254
Buggy source:
/** 
 * Override the base class to set type constraints.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return A new instance of Sleep.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Sleep newObject=(Sleep)super.clone(workspace);
  newObject.output.setTypeAtLeast(input);
  return newObject;
}

Fixed version (ground truth):
/** 
 * Override the base class to set type constraints.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return A new instance of Sleep.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Sleep newObject=(Sleep)super.clone(workspace);
  newObject.output.setTypeAtLeast(newObject.input);
  return newObject;
}
Program: 75255
Project: 75255
Buggy source:
/** 
 * Make a state transition if this FSM is embedded in SDF. Otherwise, request a change of state transition to the manager. <p>
 * @return True if the FSM is inside SDF and the super classmethod returns true; otherwise return true if the postfire of the current state refinement returns true.
 * @exception IllegalActionException If a refinement throws it,if there is no controller.
 */
public boolean postfire() throws IllegalActionException {
  FSMActor controller=getController();
  State currentState=controller.currentState();
  CompositeActor container=(CompositeActor)getContainer();
  TypedActor[] currentRefinement=currentState.getRefinement();
  if (currentRefinement == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  boolean postfireReturn=currentRefinement[0].postfire();
  if (_sendRequest && !_embeddedInSDF) {
    _sendRequest=false;
    ChangeRequest request=new ChangeRequest(this,"String_Node_Str"){
      protected void _execute() throws KernelException {
        _sendRequest=true;
        makeStateTransition();
      }
    }
;
    request.setPersistent(false);
    container.requestChange(request);
  }
  if (_embeddedInSDF) {
    makeStateTransition();
  }
  return postfireReturn;
}

Fixed version (ground truth):
/** 
 * Make a state transition if this FSM is embedded in SDF. Otherwise, request a change of state transition to the manager. <p>
 * @return True if the FSM is inside SDF and the super classmethod returns true; otherwise return true if the postfire of the current state refinement returns true.
 * @exception IllegalActionException If a refinement throws it,if there is no controller.
 */
public boolean postfire() throws IllegalActionException {
  FSMActor controller=getController();
  State currentState=_previousIntransientState;
  CompositeActor container=(CompositeActor)getContainer();
  TypedActor[] currentRefinement=currentState.getRefinement();
  if (currentRefinement == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  boolean postfireReturn=currentRefinement[0].postfire();
  if (_sendRequest && !_embeddedInSDF) {
    _sendRequest=false;
    ChangeRequest request=new ChangeRequest(this,"String_Node_Str"){
      protected void _execute() throws KernelException {
        _sendRequest=true;
        makeStateTransition();
      }
    }
;
    request.setPersistent(false);
    container.requestChange(request);
  }
  if (_embeddedInSDF) {
    makeStateTransition();
  }
  return postfireReturn;
}
Program: 75260
Project: 75260
Buggy source:
/** 
 * Return the depth of the given type.  Most simple types have depth one, while structured types have depth greater than one.
 */
public static int getTypeDepth(ptolemy.data.type.Type type){
  if (type instanceof ptolemy.data.type.ArrayType) {
    return 1 + getTypeDepth(((ptolemy.data.type.ArrayType)type).getElementType());
  }
 else   if (type instanceof ptolemy.data.type.RecordType) {
    ptolemy.data.type.RecordType recordType=(ptolemy.data.type.RecordType)type;
    Iterator labels=recordType.labelSet().iterator();
    int maxDepth=0;
    while (labels.hasNext()) {
      ptolemy.data.type.Type elementType=recordType.get((String)labels.next());
      int depth=getTypeDepth(elementType);
      if (depth > maxDepth)       maxDepth=depth;
    }
    return maxDepth + 1;
  }
 else   if (type.equals(BaseType.UNKNOWN) || type.equals(BaseType.GENERAL) || !type.isInstantiable()) {
    return Integer.MIN_VALUE;
  }
 else {
    return 1;
  }
}

Fixed version (ground truth):
/** 
 * Return the depth of the given type.  Most simple types have depth one, while structured types have depth greater than one.
 */
public static int getTypeDepth(ptolemy.data.type.Type type){
  if (type instanceof ptolemy.data.type.ArrayType) {
    return 1 + getTypeDepth(((ptolemy.data.type.ArrayType)type).getElementType());
  }
 else   if (type instanceof ptolemy.data.type.RecordType) {
    ptolemy.data.type.RecordType recordType=(ptolemy.data.type.RecordType)type;
    Iterator labels=recordType.labelSet().iterator();
    int maxDepth=0;
    while (labels.hasNext()) {
      ptolemy.data.type.Type elementType=recordType.get((String)labels.next());
      int depth=getTypeDepth(elementType);
      if (depth > maxDepth)       maxDepth=depth;
    }
    return maxDepth + 1;
  }
 else   if (!isExactTokenType(type)) {
    return Integer.MIN_VALUE;
  }
 else {
    return 1;
  }
}
Program: 75266
Project: 75266
Buggy source:
/** 
 * Return true if the argument has the same time value.
 * @param object An instance of Time.
 * @return True if the argument has the same time value.
 */
public boolean equals(Time time){
  return (time.getTimeValue() == _time);
}

Fixed version (ground truth):
/** 
 * Return true if the argument has the same time value.
 * @param time An instance of Time.
 * @return True if the argument has the same time value.
 */
public boolean equals(Time time){
  return (time.getTimeValue() == _time);
}
Program: 75268
Project: 75268
Buggy source:
/** 
 * Execute previously requested changes. If there is a container, then delegate the request to the container.  Otherwise, this method will execute all pending changes (even if  {@link #isDeferringChangeRequests()} returns true. Listeners will be notified of success or failure.
 * @see #addChangeListener(ChangeListener)
 * @see #requestChange(ChangeRequest)
 * @see #isDeferringChangeRequests()
 * @see Changeable
 */
public void executeChangeRequests(){
  NamedObj container=(NamedObj)getContainer();
  if (container != null) {
    container.executeChangeRequests();
    return;
  }
  List copy=null;
synchronized (_changeLock) {
    if (_changeRequests != null && _changeRequests.size() > 0) {
      copy=new LinkedList(_changeRequests);
      _changeRequests.clear();
    }
  }
  if (copy != null) {
    Iterator requests=copy.iterator();
    boolean previousDeferStatus=isDeferringChangeRequests();
    try {
      setDeferringChangeRequests(true);
      while (requests.hasNext()) {
        ChangeRequest change=(ChangeRequest)requests.next();
        change.setListeners(_changeListeners);
        if (_debugging) {
          _debug("String_Node_Str" + "String_Node_Str" + change.getDescription());
        }
        change.execute();
      }
    }
  finally {
      setDeferringChangeRequests(previousDeferStatus);
    }
    executeChangeRequests();
  }
}

Fixed version (ground truth):
/** 
 * Execute previously requested changes. If there is a container, then delegate the request to the container.  Otherwise, this method will execute all pending changes (even if  {@link #isDeferringChangeRequests()} returns true. Listeners will be notified of success or failure.
 * @see #addChangeListener(ChangeListener)
 * @see #requestChange(ChangeRequest)
 * @see #isDeferringChangeRequests()
 * @see Changeable
 */
public void executeChangeRequests(){
  NamedObj container=(NamedObj)getContainer();
  if (container != null) {
    container.executeChangeRequests();
    return;
  }
  List copy=null;
synchronized (_changeLock) {
    if (_changeRequests != null && _changeRequests.size() > 0) {
      copy=new LinkedList(_changeRequests);
      _changeRequests.clear();
    }
  }
  if (copy != null) {
    Iterator requests=copy.iterator();
    boolean previousDeferStatus=isDeferringChangeRequests();
    try {
      previousDeferStatus=setDeferringChangeRequests(true);
      while (requests.hasNext()) {
        ChangeRequest change=(ChangeRequest)requests.next();
        change.setListeners(_changeListeners);
        if (_debugging) {
          _debug("String_Node_Str" + "String_Node_Str" + change.getDescription());
        }
        change.execute();
      }
    }
  finally {
      setDeferringChangeRequests(previousDeferStatus);
    }
    executeChangeRequests();
  }
}
Program: 75270
Project: 75270
Buggy source:
/** 
 * Specify whether change requests made by calls to requestChange() should be executed immediately. If there is a container, then this request is delegated to the container. Otherwise, if the argument is true, then requests are simply queued until either this method is called again with argument false, or until executeChangeRequests() is called. If the argument is false, then execute any pending change requests and set a flag requesting that future requests be executed immediately.
 * @param isDeferring If true, defer change requests.
 * @see #addChangeListener(ChangeListener)
 * @see #executeChangeRequests()
 * @see #isDeferringChangeRequests()
 * @see #requestChange(ChangeRequest)
 * @see Changeable
 */
public void setDeferringChangeRequests(boolean isDeferring){
  NamedObj container=(NamedObj)getContainer();
  if (container != null) {
    container.setDeferringChangeRequests(isDeferring);
    return;
  }
synchronized (_changeLock) {
    _deferChangeRequests=isDeferring;
    if (isDeferring == false) {
      executeChangeRequests();
    }
  }
}

Fixed version (ground truth):
/** 
 * Specify whether change requests made by calls to requestChange() should be executed immediately. If there is a container, then this request is delegated to the container. Otherwise, if the argument is true, then requests are simply queued until either this method is called again with argument false, or until executeChangeRequests() is called. If the argument is false, then execute any pending change requests and set a flag requesting that future requests be executed immediately.
 * @param isDeferring If true, defer change requests.
 * @return True if this object was previously deferring changerequests.
 * @see #addChangeListener(ChangeListener)
 * @see #executeChangeRequests()
 * @see #isDeferringChangeRequests()
 * @see #requestChange(ChangeRequest)
 * @see Changeable
 */
public boolean setDeferringChangeRequests(boolean isDeferring){
  NamedObj container=(NamedObj)getContainer();
  if (container != null) {
    return container.setDeferringChangeRequests(isDeferring);
  }
synchronized (_changeLock) {
    boolean result=_deferChangeRequests;
    _deferChangeRequests=isDeferring;
    if (isDeferring == false) {
      executeChangeRequests();
    }
    return result;
  }
}
Program: 75272
Project: 75272
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new port with no connections and no container.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 * @return A new Port.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Port newObject=(Port)super.clone(workspace);
  newObject._relationsList=new CrossRefList(newObject);
  newObject._container=null;
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new port with no connections and no container.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 * @return A new Port.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Port newObject=(Port)super.clone(workspace);
  newObject._relationsList=new CrossRefList(newObject);
  newObject._insideLinks=new CrossRefList(newObject);
  newObject._container=null;
  return newObject;
}
Program: 75274
Project: 75274
Buggy source:
/** 
 * The actor is enabled if the tokenConsumptionRate on each input port is satisfied by all receivers contained by this port.
 * @param actor The actor to be checked.
 * @return true if the actor is enabled, false if not.
 * @throws IllegalActionException If any called method throwsIllegalActionException.
 */
protected boolean _isEnabled(Actor actor) throws IllegalActionException {
  Iterator inputPorts=actor.inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    int tokenConsumptionRate=1;
    Parameter parameter=(Parameter)inputPort.getAttribute("String_Node_Str");
    if (parameter == null) {
      parameter=(Parameter)inputPort.getAttribute("String_Node_Str");
    }
    if (parameter != null) {
      Token token=parameter.getToken();
      if (token instanceof ArrayToken) {
        Token[] tokens=((ArrayToken)token).arrayValue();
        if (tokens.length < inputPort.getWidth())         throw new IllegalActionException(this,(ComponentEntity)actor,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
        for (int i=0; i < inputPort.getWidth(); i++) {
          int channelRate=((IntToken)tokens[i]).intValue();
          if (!inputPort.hasToken(i,channelRate)) {
            return false;
          }
        }
        return true;
      }
 else {
        tokenConsumptionRate=((IntToken)token).intValue();
      }
    }
    for (int i=0; i < inputPort.getWidth(); i++) {
      if (!inputPort.hasToken(i,tokenConsumptionRate)) {
        return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * The actor is enabled if the tokenConsumptionRate on each input port is satisfied by all receivers contained by this port.
 * @param actor The actor to be checked.
 * @return true if the actor is enabled, false if not.
 * @throws IllegalActionException If any called method throwsIllegalActionException.
 */
protected boolean _isEnabled(Actor actor) throws IllegalActionException {
  Iterator inputPorts=actor.inputPortList().iterator();
  while (inputPorts.hasNext()) {
    IOPort inputPort=(IOPort)inputPorts.next();
    int tokenConsumptionRate=1;
    Variable parameter=SDFUtilities.getRateVariable(inputPort,"String_Node_Str");
    if (parameter != null) {
      Token token=parameter.getToken();
      if (token instanceof ArrayToken) {
        Token[] tokens=((ArrayToken)token).arrayValue();
        if (tokens.length < inputPort.getWidth())         throw new IllegalActionException(this,(ComponentEntity)actor,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
        for (int i=0; i < inputPort.getWidth(); i++) {
          int channelRate=((IntToken)tokens[i]).intValue();
          if (!inputPort.hasToken(i,channelRate)) {
            return false;
          }
        }
        return true;
      }
 else {
        tokenConsumptionRate=((IntToken)token).intValue();
      }
    }
    for (int i=0; i < inputPort.getWidth(); i++) {
      if (!inputPort.hasToken(i,tokenConsumptionRate)) {
        return false;
      }
    }
  }
  return true;
}
Program: 75275
Project: 75275
Buggy source:
/** 
 * Get token production rate for the given port.
 * @param port The port to get token production rate.
 * @return An int array of token production rate.
 * @throws IllegalActionException If parameter throws itor the length of tokenProductionRate array is less  than port inside width.
 */
private int[] _getTokenProductionRate(IOPort port) throws IllegalActionException {
  int[] rate=new int[port.getWidthInside()];
  Arrays.fill(rate,1);
  Parameter parameter=(Parameter)port.getAttribute("String_Node_Str");
  if (parameter == null)   parameter=(Parameter)port.getAttribute("String_Node_Str");
  if (parameter != null) {
    Token token=parameter.getToken();
    if (token instanceof ArrayToken) {
      Token[] tokens=((ArrayToken)token).arrayValue();
      if (tokens.length < port.getWidthInside())       throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      for (int i=0; i < port.getWidthInside(); i++)       rate[i]=((IntToken)tokens[i]).intValue();
    }
 else {
      Arrays.fill(rate,((IntToken)token).intValue());
    }
  }
  return rate;
}

Fixed version (ground truth):
/** 
 * Get token production rate for the given port.
 * @param port The port to get token production rate.
 * @return An int array of token production rate.
 * @throws IllegalActionException If parameter throws itor the length of tokenProductionRate array is less  than port inside width.
 */
private int[] _getTokenProductionRate(IOPort port) throws IllegalActionException {
  int[] rate=new int[port.getWidthInside()];
  Arrays.fill(rate,1);
  Variable parameter=SDFUtilities.getRateVariable(port,"String_Node_Str");
  if (parameter != null) {
    Token token=parameter.getToken();
    if (token instanceof ArrayToken) {
      Token[] tokens=((ArrayToken)token).arrayValue();
      if (tokens.length < port.getWidthInside())       throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      for (int i=0; i < port.getWidthInside(); i++)       rate[i]=((IntToken)tokens[i]).intValue();
    }
 else {
      Arrays.fill(rate,((IntToken)token).intValue());
    }
  }
  return rate;
}
Program: 75276
Project: 75276
Buggy source:
/** 
 * Get token consumption rate for the given port.
 * @param port The port to get token consumption rate.
 * @return An int array of token consumption rate.
 * @throws IllegalActionException If parameter throws it or the length of tokenConsumptionRate array is less than port width.
 */
private int[] _getTokenConsumptionRate(IOPort port) throws IllegalActionException {
  int[] rate=new int[port.getWidth()];
  Arrays.fill(rate,1);
  Parameter parameter=(Parameter)port.getAttribute("String_Node_Str");
  if (parameter == null)   parameter=(Parameter)port.getAttribute("String_Node_Str");
  if (parameter != null) {
    Token token=parameter.getToken();
    if (token instanceof ArrayToken) {
      Token[] tokens=((ArrayToken)token).arrayValue();
      if (tokens.length < port.getWidth())       throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      for (int i=0; i < port.getWidth(); i++)       rate[i]=((IntToken)tokens[i]).intValue();
    }
 else {
      Arrays.fill(rate,((IntToken)token).intValue());
    }
  }
  return rate;
}

Fixed version (ground truth):
/** 
 * Get token consumption rate for the given port.
 * @param port The port to get token consumption rate.
 * @return An int array of token consumption rate.
 * @throws IllegalActionException If parameter throws it or the length of tokenConsumptionRate array is less than port width.
 */
private int[] _getTokenConsumptionRate(IOPort port) throws IllegalActionException {
  int[] rate=new int[port.getWidth()];
  Arrays.fill(rate,1);
  Variable parameter=SDFUtilities.getRateVariable(port,"String_Node_Str");
  if (parameter != null) {
    Token token=parameter.getToken();
    if (token instanceof ArrayToken) {
      Token[] tokens=((ArrayToken)token).arrayValue();
      if (tokens.length < port.getWidth())       throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      for (int i=0; i < port.getWidth(); i++)       rate[i]=((IntToken)tokens[i]).intValue();
    }
 else {
      Arrays.fill(rate,((IntToken)token).intValue());
    }
  }
  return rate;
}
Program: 75277
Project: 75277
Buggy source:
/** 
 * Adjust the deferrals in this object. Specifically, if this object has a class name that refers to a class in scope, then replace the current parent with that object.
 * @exception IllegalActionException If the class found in scopecannot be set.
 */
protected void _adjustDeferrals() throws IllegalActionException {
  String className=getClassName();
  NamedObj context=this;
  ComponentEntity candidate=null;
  while ((candidate == null || !candidate.isClassDefinition()) && context != null) {
    context=(NamedObj)context.getContainer();
    if (context instanceof CompositeEntity) {
      candidate=((CompositeEntity)context).getEntity(className);
    }
  }
  if (candidate != null) {
    _setParent(candidate);
    _markContentsDerived(0);
    candidate.propagateValues();
  }
}

Fixed version (ground truth):
/** 
 * Adjust the deferrals in this object. This method should be called on any newly created object that is created by cloning. While cloning, parent relations are set to null. That is, no object in the clone has a parent. This method identifies the correct parent for any object in the clone. To do this, it uses the class name. Specifically, if this object has a class name that refers to a class in scope, then it replaces the current parent with that object. To look for a class in scope, we go up the hierarchy, but no more times than the return value of getDerivedLevel(). The reason for this is that if the class from which this object is defined is above that level, then we do not want to establish a parent relationship with that class. This object is implied, and the parent relationship of the object from which it is implied is sufficient. <p> Derived classes that contain other objects should recursively call this method on contained objects.
 * @exception IllegalActionException If the class found in scopecannot be set.
 */
protected void _adjustDeferrals() throws IllegalActionException {
  String className=getClassName();
  NamedObj context=this;
  int levelsToSearch=getDerivedLevel();
  int aboveLevel=0;
  ComponentEntity candidate=null;
  while (aboveLevel < levelsToSearch && (candidate == null || !candidate.isClassDefinition()) && context != null) {
    context=(NamedObj)context.getContainer();
    if (context instanceof CompositeEntity) {
      candidate=((CompositeEntity)context).getEntity(className);
    }
    aboveLevel+=1;
  }
  if (candidate != null) {
    _setParent(candidate);
    _markContentsDerived(0);
    candidate.propagateValues();
  }
}
Program: 75278
Project: 75278
Buggy source:
/** 
 * Adjust the deferrals in this object. Specifically, if this object has a class name that refers to a class in scope, then replace the current parent with that object. Override the base class to also call the same method on all contained class definitions and ordinary entities.
 * @exception IllegalActionException If the class found in scopecannot be set.
 */
protected void _adjustDeferrals() throws IllegalActionException {
  super._adjustDeferrals();
  Iterator containedClasses=classDefinitionList().iterator();
  while (containedClasses.hasNext()) {
    NamedObj containedObject=(NamedObj)containedClasses.next();
    if (containedObject instanceof ComponentEntity) {
      ((ComponentEntity)containedObject)._adjustDeferrals();
    }
  }
  Iterator containedEntities=entityList().iterator();
  while (containedEntities.hasNext()) {
    NamedObj containedObject=(NamedObj)containedEntities.next();
    if (containedObject instanceof ComponentEntity) {
      ((ComponentEntity)containedObject)._adjustDeferrals();
    }
  }
}

Fixed version (ground truth):
/** 
 * Adjust the deferrals in this object. This method should be called on any newly created object that is created by cloning. While cloning, parent relations are set to null. That is, no object in the clone has a parent. This method identifies the correct parent for any object in the clone. To do this, it uses the class name. Specifically, if this object has a class name that refers to a class in scope, then it replaces the current parent with that object. To look for a class in scope, we go up the hierarchy, but no more times than the return value of getDerivedLevel(). The reason for this is that if the class from which this object is defined is above that level, then we do not want to establish a parent relationship with that class. This object is implied, and the parent relationship of the object from which it is implied is sufficient. <p> Derived classes that contain other objects should recursively call this method on contained objects.
 * @exception IllegalActionException If the class found in scopecannot be set.
 */
protected void _adjustDeferrals() throws IllegalActionException {
  super._adjustDeferrals();
  Iterator containedClasses=classDefinitionList().iterator();
  while (containedClasses.hasNext()) {
    NamedObj containedObject=(NamedObj)containedClasses.next();
    if (containedObject instanceof ComponentEntity) {
      ((ComponentEntity)containedObject)._adjustDeferrals();
    }
  }
  Iterator containedEntities=entityList().iterator();
  while (containedEntities.hasNext()) {
    NamedObj containedObject=(NamedObj)containedEntities.next();
    if (containedObject instanceof ComponentEntity) {
      ((ComponentEntity)containedObject)._adjustDeferrals();
    }
  }
}
Program: 75279
Project: 75279
Buggy source:
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new instance of InstantiableNamedObj that is a child of the parent of this object, if this object has a parent. The new instance has no children. This method gets read access on the workspace associated with this object.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 * @return A new instance of InstantiableNamedObj.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  try {
    workspace().getReadAccess();
    InstantiableNamedObj newObject=(InstantiableNamedObj)super.clone(workspace);
    newObject._children=null;
    newObject._parent=null;
    if (_parent != null) {
      try {
        newObject._setParent(_parent);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex);
      }
    }
    return newObject;
  }
  finally {
    workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). The result is a new instance of InstantiableNamedObj that is a child of the parent of this object, if this object has a parent. The new instance has no children. This method gets read access on the workspace associated with this object.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If one of the attributescannot be cloned.
 * @return A new instance of InstantiableNamedObj.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  try {
    workspace().getReadAccess();
    InstantiableNamedObj newObject=(InstantiableNamedObj)super.clone(workspace);
    newObject._children=null;
    newObject._parent=null;
    return newObject;
  }
  finally {
    workspace().doneReading();
  }
}
Program: 75280
Project: 75280
Buggy source:
/** 
 * Output the data read in the prefire.
 * @exception IllegalActionException If there's no director orif the directory or URL is invalid.
 */
public void fire() throws IllegalActionException {
  super.fire();
  URL sourceURL=directoryOrURL.asURL();
  if (sourceURL == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  if (sourceURL.getProtocol().equals("String_Node_Str")) {
    File sourceFile=directoryOrURL.asFile();
    if (sourceFile.isDirectory()) {
      File[] files=sourceFile.listFiles(this);
      StringToken[] result=new StringToken[files.length];
      for (int i=0; i < files.length; i++) {
        result[i]=new StringToken(files[i].getAbsolutePath());
      }
      output.broadcast(new ArrayToken(result));
      return;
    }
 else     if (sourceFile.isFile()) {
      StringToken[] result=new StringToken[1];
      result[0]=new StringToken(sourceFile.toString());
      output.broadcast(new ArrayToken(result));
      return;
    }
 else {
      throw new IllegalActionException("String_Node_Str" + directoryOrURL + "String_Node_Str"+ "String_Node_Str");
    }
  }
 else {
    try {
      _readURL(sourceURL);
    }
 catch (    IOException ex) {
      throw new IllegalActionException(this,ex,"String_Node_Str" + directoryOrURL + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Output the data read in the prefire.
 * @exception IllegalActionException If there's no director orif the directory or URL is invalid.
 */
public void fire() throws IllegalActionException {
  super.fire();
  if (directoryOrURLPort.getWidth() > 0 && directoryOrURLPort.hasToken(0)) {
    String newValue=((StringToken)directoryOrURLPort.get(0)).stringValue();
    directoryOrURL.setExpression(newValue);
  }
  URL sourceURL=directoryOrURL.asURL();
  if (sourceURL == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  if (sourceURL.getProtocol().equals("String_Node_Str")) {
    File sourceFile=directoryOrURL.asFile();
    if (sourceFile.isDirectory()) {
      File[] files=sourceFile.listFiles(this);
      StringToken[] result=new StringToken[files.length];
      for (int i=0; i < files.length; i++) {
        result[i]=new StringToken(files[i].getAbsolutePath());
      }
      output.broadcast(new ArrayToken(result));
      return;
    }
 else     if (sourceFile.isFile()) {
      StringToken[] result=new StringToken[1];
      result[0]=new StringToken(sourceFile.toString());
      output.broadcast(new ArrayToken(result));
      return;
    }
 else {
      throw new IllegalActionException("String_Node_Str" + directoryOrURL + "String_Node_Str"+ "String_Node_Str");
    }
  }
 else {
    try {
      _readURL(sourceURL);
    }
 catch (    IOException ex) {
      throw new IllegalActionException(this,ex,"String_Node_Str" + directoryOrURL + "String_Node_Str");
    }
  }
}