nus-yam/ex-repair huggingface dataset:
Program: 75989
Project: 75989
Buggy source:
/** 
 * Return the scheduling sequence as an instance of Schedule. For efficiency, this method returns a cached version of the schedule, if it is valid.  Otherwise, it calls the protected method _getSchedule() to update the schedule.  Derived classes would normally override the protected method, not this one. The validity of the current schedule is set by the setValid() method. This method is read-synchronized on the workspace.
 * @return The Schedule returned by the _getSchedule() method.
 * @exception IllegalActionException If the scheduler has no container(a director), or the director has no container (a CompositeActor).
 * @exception NotSchedulableException If the _getSchedule() methodthrows it. Not thrown in this base class, but may be needed by the derived schedulers.
 */
public Schedule getSchedule() throws IllegalActionException, NotSchedulableException {
  try {
    workspace().getReadAccess();
    StaticSchedulingDirector dir=(StaticSchedulingDirector)getContainer();
    if (dir == null) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    CompositeActor ca=(CompositeActor)(dir.getContainer());
    if (ca == null) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    if (!isValid()) {
      _cachedGetSchedule=_getSchedule();
    }
    if (_cachedGetSchedule == null) {
      _cachedGetSchedule=_getSchedule();
    }
    return _cachedGetSchedule;
  }
  finally {
    workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Return the scheduling sequence as an instance of Schedule. For efficiency, this method returns a cached version of the schedule, if it is valid.  Otherwise, it calls the protected method _getSchedule() to update the schedule.  Derived classes would normally override the protected method, not this one. The validity of the current schedule is set by the setValid() method. This method is read-synchronized on the workspace.
 * @return The Schedule returned by the _getSchedule() method.
 * @exception IllegalActionException If the scheduler has no container(a director), or the director has no container (a CompositeActor).
 * @exception NotSchedulableException If the _getSchedule() methodthrows it. Not thrown in this base class, but may be needed by the derived schedulers.
 */
public Schedule getSchedule() throws IllegalActionException, NotSchedulableException {
  try {
    workspace().getReadAccess();
    StaticSchedulingDirector dir=(StaticSchedulingDirector)getContainer();
    if (dir == null) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    CompositeActor ca=(CompositeActor)(dir.getContainer());
    if (ca == null) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
    if (!isValid() || _cachedGetSchedule == null) {
      _cachedGetSchedule=_getSchedule();
    }
    return _cachedGetSchedule;
  }
  finally {
    workspace().doneReading();
  }
}
Program: 75990
Project: 75990
Buggy source:
/** 
 * Set the scheduler for this StaticSchedulingDirector. The container of the specified scheduler is set to this director. If there was a previous scheduler, the container of that scheduler is set to null. This method is write-synchronized on the workspace. If the scheduler is not compatible with the director, an IllegalActionException is thrown.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException Not thrown in this base class,but derived classes may throw it if the scheduler is not compatible.
 */
public void setScheduler(Scheduler scheduler) throws IllegalActionException {
  if (scheduler != null && workspace() != scheduler.workspace()) {
    throw new IllegalActionException(this,scheduler,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (_scheduler != null)     _scheduler._makeSchedulerOf(null);
    if (scheduler != null) {
      scheduler._makeSchedulerOf(this);
    }
    _scheduler=scheduler;
  }
  finally {
    workspace().doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Set the scheduler for this StaticSchedulingDirector. The container of the specified scheduler is set to this director. If there was a previous scheduler, the container of that scheduler is set to null. This method is write-synchronized on the workspace. If the scheduler is not compatible with the director, an IllegalActionException is thrown.
 * @param director The Director responsible for execution.
 * @exception IllegalActionException Not thrown in this base class,but derived classes may throw it if the scheduler is not compatible.
 */
public void setScheduler(Scheduler scheduler) throws IllegalActionException {
  if (scheduler != null && workspace() != scheduler.workspace()) {
    throw new IllegalActionException(this,scheduler,"String_Node_Str");
  }
  try {
    workspace().getWriteAccess();
    if (_scheduler != null) {
      _scheduler._makeSchedulerOf(null);
    }
    _scheduler=scheduler;
    if (scheduler != null) {
      scheduler._makeSchedulerOf(this);
    }
  }
  finally {
    workspace().doneWriting();
  }
}
Program: 75993
Project: 75993
Buggy source:
/** 
 * Get the name of this object relative to the specified container.  A recursive structure, where this object is directly or indirectly contained by itself, may result in a runtime exception of class InvalidStateException if it is detected.  Note that it is not possible to construct a recursive structure using this class alone, since there is no container. But derived classes might erroneously permit recursive structures, so this error is caught here. If the given container is not actually a container of this object, or is null, then the full name of the object is returned. This method is read-synchronized on the workspace.
 * @param parent An object that deeply contains this object.
 * @return A string of the form "name2...nameN".
 */
public String getName(NamedObj parent){
  if (parent == null) {
    return getFullName();
  }
  try {
    _workspace.getReadAccess();
    String name=getName();
    Set visited=new HashSet();
    visited.add(this);
    Nameable container=getContainer();
    while (container != null && container != parent) {
      if (visited.contains(container)) {
        throw new InvalidStateException("String_Node_Str");
      }
      name=container.getName() + "String_Node_Str" + name;
      visited.add(container);
      container=container.getContainer();
    }
    if (container == null) {
      return getFullName();
    }
    return name;
  }
  finally {
    _workspace.doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Get the name of this object relative to the specified container. A recursive structure, where this object is directly or indirectly contained by itself, may result in a runtime exception of class InvalidStateException if it is detected.  Note that it is not possible to construct a recursive structure using this class alone, since there is no container. But derived classes might erroneously permit recursive structures, so this error is caught here. If the given container is not actually a container of this object, or is null, then the full name of the object is returned. This method is read-synchronized on the workspace.
 * @param parent An object that deeply contains this object.
 * @return A string of the form "name2...nameN".
 */
public String getName(NamedObj parent){
  if (parent == null) {
    return getFullName();
  }
  try {
    _workspace.getReadAccess();
    String name=getName();
    Set visited=new HashSet();
    visited.add(this);
    Nameable container=getContainer();
    while (container != null && container != parent) {
      if (visited.contains(container)) {
        throw new InvalidStateException("String_Node_Str");
      }
      name=container.getName() + "String_Node_Str" + name;
      visited.add(container);
      container=container.getContainer();
    }
    if (container == null) {
      return getFullName();
    }
    return name;
  }
  finally {
    _workspace.doneReading();
  }
}
Program: 75996
Project: 75996
Buggy source:
/** 
 * Increment the iteration counter, and if it equals the value of the <i>firingCountLimit</i> parameter, return false. Otherwise, return true.  Derived classes should call this at the end of their postfire() method and return its returned value.
 * @exception IllegalActionException If firingCountLimit hasan invalid expression.
 */
public boolean postfire() throws IllegalActionException {
  _iterationCount++;
  if (_iterationCount == ((IntToken)firingCountLimit.getToken()).intValue()) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Increment the iteration counter, and if it equals the value of the <i>firingCountLimit</i> parameter, return false. Otherwise, return true.  Derived classes should call this at the end of their postfire() method and return its returned value.
 * @exception IllegalActionException If firingCountLimit hasan invalid expression.
 */
public boolean postfire() throws IllegalActionException {
  if (_firingCountLimit != 0) {
    _iterationCount++;
    if (_iterationCount == _firingCountLimit) {
      return false;
    }
  }
  return true;
}
Program: 75998
Project: 75998
Buggy source:
/** 
 * Return false if there is no more actor to fire. Otherwise, if the director is an embedded director and the queue is not empty, then requests the executive director to refire the container of this director at the time of the next event in the event queue of this director. Note that when the <i>stopWhenQueueIsEmpty</i> parameter is false, and the queue is empty, the stall happens in the fire() method.
 * @exception IllegalActionException Not thrown in this base class.
 */
public boolean postfire() throws IllegalActionException {
  if (_noMoreActorsToFire) {
    return false;
  }
 else   if (_isEmbedded() && !_eventQueue.isEmpty()) {
    _requestFiring();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return false if there is no more actor to fire. Otherwise, if the director is an embedded director and the queue is not empty, then requests the executive director to refire the container of this director at the time of the next event in the event queue of this director. Note that when the <i>stopWhenQueueIsEmpty</i> parameter is false, and the queue is empty, the stall happens in the fire() method.
 * @exception IllegalActionException Not thrown in this base class.
 */
public boolean postfire() throws IllegalActionException {
  if (_noMoreActorsToFire && _exceedStopTime) {
    return false;
  }
 else   if (_isEmbedded() && !_eventQueue.isEmpty()) {
    _requestFiring();
  }
  return true;
}
Program: 75999
Project: 75999
Buggy source:
/** 
 * Invoke the initialize() method of each deeply contained actor, and then check the event queue for any events. If there are any, and the director is embedded in an opaque composite actor, then request a firing of the outside director. This method should be invoked once per execution, after the initialization phase, but before any iteration.  Since type resolution has been completed, the initialize() method of a contained actor may produce output or schedule events. The real start time of the model is recorded when this method is called. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  _realStartTime=System.currentTimeMillis();
  super.initialize();
  if (_isEmbedded() && !_eventQueue.isEmpty()) {
    _requestFiring();
  }
}

Fixed version (ground truth):
/** 
 * Invoke the initialize() method of each deeply contained actor, and then check the event queue for any events. If there are any, and the director is embedded in an opaque composite actor, then request a firing of the outside director. This method should be invoked once per execution, after the initialization phase, but before any iteration.  Since type resolution has been completed, the initialize() method of a contained actor may produce output or schedule events. The real start time of the model is recorded when this method is called. This method is <i>not</i> synchronized on the workspace, so the caller should be.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  _realStartTime=System.currentTimeMillis();
  if (!_isEmbedded() && getStartTime() > getStopTime()) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _exceedStopTime=false;
  super.initialize();
  if (_isEmbedded() && !_eventQueue.isEmpty()) {
    _requestFiring();
  }
}
Program: 76002
Project: 76002
Buggy source:
/** 
 * Calculate the function on the given argument.
 * @param in The input value.
 * @return The result of applying the function.
 */
private double _doFunction(double in1,double in2){
  double result;
switch (_function) {
case EXP:
    result=Math.exp(in1);
  break;
case LOG:
result=Math.log(in1);
break;
case SQUARE:
result=in1 * in1;
break;
case SQRT:
result=Math.sqrt(in1);
break;
case REMAINDER:
result=in1 % in2;
break;
default :
throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + getFullName() + "String_Node_Str");
}
return result;
}

Fixed version (ground truth):
/** 
 * Calculate the function on the given argument.
 * @param in The input value.
 * @return The result of applying the function.
 */
private double _doFunction(double input1,double input2){
  double result;
switch (_function) {
case EXP:
    result=Math.exp(input1);
  break;
case LOG:
result=Math.log(input1);
break;
case SQUARE:
result=input1 * input1;
break;
case SQRT:
result=Math.sqrt(input1);
break;
case REMAINDER:
result=input1 % input2;
break;
default :
throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + getFullName() + "String_Node_Str");
}
return result;
}
Program: 76003
Project: 76003
Buggy source:
/** 
 * Compute the specified math function of the input. Consumes at most one token on each input port during firing. If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  if (firstOperand.hasToken(0)) {
    double in1=((DoubleToken)firstOperand.get(0)).doubleValue();
    double in2=0;
    if (_function == REMAINDER) {
      if (secondOperand.hasToken(0)) {
        in2=((DoubleToken)secondOperand.get(0)).doubleValue();
      }
    }
    output.send(0,new DoubleToken(_doFunction(in1,in2)));
  }
}

Fixed version (ground truth):
/** 
 * Compute the specified math function of the input. Consumes at most one token on each input port during firing. If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  if (firstOperand.hasToken(0)) {
    double input1=((DoubleToken)firstOperand.get(0)).doubleValue();
    double input2=0;
    if (_function == REMAINDER) {
      if (secondOperand.hasToken(0)) {
        input2=((DoubleToken)secondOperand.get(0)).doubleValue();
      }
    }
    output.send(0,new DoubleToken(_doFunction(input1,input2)));
  }
}
Program: 76005
Project: 76005
Buggy source:
/** 
 * Construct a frame to control the specified Ptolemy II model. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This creates an instance of ModelPane and puts it in a top-level window. This is typically done by calling show() on the controlling tableau.
 * @see ModelPane
 * @see Tableau#show()
 * @param model The model to put in this frame, or null if none.
 * @param tableau The tableau responsible for this frame, or null if none.
 */
public ModelFrame(CompositeActor model,Tableau tableau){
  super(model,tableau);
  _pane=new ModelPane(model);
  getContentPane().add(_pane,BorderLayout.CENTER);
  _pane.setDefaultButton();
}

Fixed version (ground truth):
/** 
 * Construct a frame to control the specified Ptolemy II model. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This creates an instance of ModelPane and puts it in a top-level window. This is typically done by calling show() on the controlling tableau.
 * @see ModelPane
 * @see Tableau#show()
 * @param model The model to put in this frame, or null if none.
 * @param tableau The tableau responsible for this frame, or null if none.
 */
public ModelFrame(CompositeActor model,Tableau tableau){
  super(model,tableau);
  _pane=new ModelPane(model);
  getContentPane().add(_pane,BorderLayout.CENTER);
  Manager manager=model.getManager();
  if (manager != null) {
    manager.addExecutionListener(this);
  }
  _pane.setDefaultButton();
}
Program: 76007
Project: 76007
Buggy source:
/** 
 * Returns a new RecordToken representing the additive identity. The returned token has the same set of labels as this one, and each field contains the additive identity of the corresponding field of this one.
 * @return An RecordToken.
 * @exception IllegalActionException If additive identity is notsupported by the element token.
 */
public Token zero() throws IllegalActionException {
  Set labelSet=_fields.keySet();
  int size=labelSet.size();
  String[] labels=new String[size];
  Token[] values=new Token[size];
  Iterator iter=labelSet.iterator();
  int i=0;
  while (iter.hasNext()) {
    labels[i]=(String)iter.next();
    values[i]=this.get(labels[i]).zero();
  }
  return new RecordToken(labels,values);
}

Fixed version (ground truth):
/** 
 * Returns a new RecordToken representing the additive identity. The returned token has the same set of labels as this one, and each field contains the additive identity of the corresponding field of this one.
 * @return An RecordToken.
 * @exception IllegalActionException If additive identity is notsupported by the element token.
 */
public Token zero() throws IllegalActionException {
  Object[] labelsObj=_fields.keySet().toArray();
  String[] labels=new String[labelsObj.length];
  Token[] values=new Token[labels.length];
  for (int i=0; i < labels.length; i++) {
    labels[i]=(String)labelsObj[i];
    values[i]=this.get(labels[i]).zero();
  }
  return new RecordToken(labels,values);
}
Program: 76008
Project: 76008
Buggy source:
/** 
 * Returns a new RecordToken representing the multiplicative identity. The returned token has the same set of labels as this one, and each field contains the multiplicative identity of the corresponding field of this one.
 * @return An RecordToken.
 * @exception IllegalActionException If multiplicative identity is notsupported by the element token.
 */
public Token one() throws IllegalActionException {
  Set labelSet=_fields.keySet();
  int size=labelSet.size();
  String[] labels=new String[size];
  Token[] values=new Token[size];
  Iterator iter=labelSet.iterator();
  int i=0;
  while (iter.hasNext()) {
    labels[i]=(String)iter.next();
    values[i]=this.get(labels[i]).one();
  }
  return new RecordToken(labels,values);
}

Fixed version (ground truth):
/** 
 * Returns a new RecordToken representing the multiplicative identity. The returned token has the same set of labels as this one, and each field contains the multiplicative identity of the corresponding field of this one.
 * @return An RecordToken.
 * @exception IllegalActionException If multiplicative identity is notsupported by the element token.
 */
public Token one() throws IllegalActionException {
  Object[] labelsObj=_fields.keySet().toArray();
  String[] labels=new String[labelsObj.length];
  Token[] values=new Token[labels.length];
  for (int i=0; i < labels.length; i++) {
    labels[i]=(String)labelsObj[i];
    values[i]=this.get(labels[i]).one();
  }
  return new RecordToken(labels,values);
}
Program: 76009
Project: 76009
Buggy source:
/** 
 * Convert the argument token into a RecordToken having this type, if losslessly conversion can be done.  The argument must be an RecordToken, and its type must be a subtype of this record type. If this type is a variable, convert the the argument into a substitution instance of this variable.
 * @param t A token.
 * @return An RecordToken.
 * @exception IllegalActionException If lossless conversioncannot be done.
 */
public Token convert(Token t) throws IllegalActionException {
  if (!isCompatible(t)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  RecordToken argRecTok=(RecordToken)t;
  String[] labels=(String[])_fields.keySet().toArray();
  Token[] values=new Token[labels.length];
  for (int i=0; i < labels.length; i++) {
    Token orgToken=argRecTok.get(labels[i]);
    FieldType fieldType=(FieldType)_fields.get(labels[i]);
    Type type=fieldType._resolvedType;
    values[i]=type.convert(orgToken);
  }
  return new RecordToken(labels,values);
}

Fixed version (ground truth):
/** 
 * Convert the argument token into a RecordToken having this type, if losslessly conversion can be done.  The argument must be an RecordToken, and its type must be a subtype of this record type. If this type is a variable, convert the the argument into a substitution instance of this variable.
 * @param t A token.
 * @return An RecordToken.
 * @exception IllegalActionException If lossless conversioncannot be done.
 */
public Token convert(Token t) throws IllegalActionException {
  if (!isCompatible(t)) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + t.toString() + "String_Node_Str"+ this.toString());
  }
  RecordToken argRecTok=(RecordToken)t;
  Object[] labelsObj=_fields.keySet().toArray();
  String[] labels=new String[labelsObj.length];
  Token[] values=new Token[labelsObj.length];
  for (int i=0; i < labelsObj.length; i++) {
    labels[i]=(String)labelsObj[i];
    Token orgToken=argRecTok.get(labels[i]);
    FieldType fieldType=(FieldType)_fields.get(labels[i]);
    Type type=fieldType._resolvedType;
    values[i]=type.convert(orgToken);
  }
  return new RecordToken(labels,values);
}
Program: 76010
Project: 76010
Buggy source:
/** 
 * Test if the argument token is compatible with this type. If this type is a constant, the argument is compatible if it can be converted losslessly to a token of this type; If this type is a variable, the argument is compatible if its type is a substitution instance of this type, or if it can be converted losslessly to a substitution instance of this type. 
 * @param t A Token.
 * @return True if the argument is compatible with this type.
 */
public boolean isCompatible(Token t){
  if (!(t.getType() instanceof RecordToken)) {
    return false;
  }
  RecordToken argRecTok=(RecordToken)t;
  Iterator iter=_fields.keySet().iterator();
  while (iter.hasNext()) {
    String label=(String)iter.next();
    if (argRecTok.get(label) == null) {
      return false;
    }
    FieldType fieldType=(FieldType)_fields.get(label);
    Type type=fieldType._declaredType;
    Token value=(Token)argRecTok.get(label);
    if (!type.isCompatible(value)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Test if the argument token is compatible with this type. If this type is a constant, the argument is compatible if it can be converted losslessly to a token of this type; If this type is a variable, the argument is compatible if its type is a substitution instance of this type, or if it can be converted losslessly to a substitution instance of this type. 
 * @param t A Token.
 * @return True if the argument is compatible with this type.
 */
public boolean isCompatible(Token t){
  if (!(t instanceof RecordToken)) {
    return false;
  }
  RecordToken argRecTok=(RecordToken)t;
  Iterator iter=_fields.keySet().iterator();
  while (iter.hasNext()) {
    String label=(String)iter.next();
    if (argRecTok.get(label) == null) {
      return false;
    }
    FieldType fieldType=(FieldType)_fields.get(label);
    Type type=fieldType._declaredType;
    Token value=(Token)argRecTok.get(label);
    if (!type.isCompatible(value)) {
      return false;
    }
  }
  return true;
}
Program: 76011
Project: 76011
Buggy source:
/** 
 * Return a deep copy of this RecordType if it is a variable, or itself if it is a constant.
 * @return A RecordType.
 */
public Object clone(){
  if (isConstant()) {
    return this;
  }
 else {
    String[] labels=(String[])_fields.keySet().toArray();
    Type[] types=new Type[labels.length];
    for (int i=0; i < labels.length; i++) {
      FieldType fieldType=(FieldType)_fields.get(labels[i]);
      types[i]=fieldType._declaredType;
    }
    RecordType newObj=new RecordType(labels,types);
    try {
      newObj.updateType(this);
    }
 catch (    IllegalActionException ex) {
      throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
    }
    return newObj;
  }
}

Fixed version (ground truth):
/** 
 * Return a deep copy of this RecordType if it is a variable, or itself if it is a constant.
 * @return A RecordType.
 */
public Object clone(){
  if (isConstant()) {
    return this;
  }
 else {
    Object[] labelsObj=_fields.keySet().toArray();
    String[] labels=new String[labelsObj.length];
    Type[] types=new Type[labelsObj.length];
    for (int i=0; i < labels.length; i++) {
      labels[i]=(String)labelsObj[i];
      FieldType fieldType=(FieldType)_fields.get(labels[i]);
      types[i]=fieldType._declaredType;
    }
    RecordType newObj=new RecordType(labels,types);
    try {
      newObj.updateType(this);
    }
 catch (    IllegalActionException ex) {
      throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + ex.getMessage());
    }
    return newObj;
  }
}
Program: 76012
Project: 76012
Buggy source:
/** 
 * Update this Type to the specified RecordType. The specified type must be a substitution instance of this type. This method will only update the component whose declared type is BaseType.ANY, and leave the constant part of this type intact.
 * @param st A StructuredType.
 * @exception IllegalActionException If the specified type is not asubstitution instance of this type.
 */
public void updateType(StructuredType newType) throws IllegalActionException {
  if (!this.isSubstitutionInstance(newType)) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  Iterator iter=_fields.keySet().iterator();
  while (iter.hasNext()) {
    String label=(String)iter.next();
    FieldType fieldType=(FieldType)this.get(label);
    if (fieldType.isSettable()) {
      Type newFieldType=((RecordType)newType).get(label);
      fieldType.setValue(newFieldType);
    }
  }
}

Fixed version (ground truth):
/** 
 * Update this Type to the specified RecordType. The specified type must be a substitution instance of this type. This method will only update the component whose declared type is BaseType.ANY, and leave the constant part of this type intact.
 * @param st A StructuredType.
 * @exception IllegalActionException If the specified type is not asubstitution instance of this type.
 */
public void updateType(StructuredType newType) throws IllegalActionException {
  if (!this.isSubstitutionInstance(newType)) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  Iterator iter=_fields.keySet().iterator();
  while (iter.hasNext()) {
    String label=(String)iter.next();
    FieldType fieldType=(FieldType)_fields.get(label);
    if (fieldType.isSettable()) {
      Type newFieldType=((RecordType)newType).get(label);
      fieldType.setValue(newFieldType);
    }
  }
}
Program: 76013
Project: 76013
Buggy source:
/** 
 * Construct a RecordToken with the specified labeles and values.  The labels and values array must have the same length, and have one to correspondance. That is, the i'th entry in the labels array is the label for the i'th value in the values array. Both arrays must be non-empty.
 * @param labels An array of labels.
 * @param values An array of Tokens.
 * @exception IllegalArgumentException If the labels or the values arraydo not have the same length; or is empty; or contains null element; or the labels array contains duplicate elements.
 */
public RecordToken(String[] labels,Token[] values){
  if (labels == null || values == null || labels.length != values.length) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  for (int i=0; i < labels.length; i++) {
    if (labels[i] == null || values[i] == null) {
      throw new IllegalArgumentException("String_Node_Str" + i + "String_Node_Str");
    }
    if (_fields.containsKey(labels[i])) {
      _fields.put(labels[i],values[i]);
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + labels[i]);
    }
  }
}

Fixed version (ground truth):
/** 
 * Construct a RecordToken with the specified labeles and values.  The labels and values array must have the same length, and have one to correspondance. That is, the i'th entry in the labels array is the label for the i'th value in the values array. Both arrays must be non-empty.
 * @param labels An array of labels.
 * @param values An array of Tokens.
 * @exception IllegalArgumentException If the labels or the values arraydo not have the same length; or is empty; or contains null element; or the labels array contains duplicate elements.
 */
public RecordToken(String[] labels,Token[] values){
  if (labels == null || values == null || labels.length != values.length) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  for (int i=0; i < labels.length; i++) {
    if (labels[i] == null || values[i] == null) {
      throw new IllegalArgumentException("String_Node_Str" + i + "String_Node_Str");
    }
    if (!_fields.containsKey(labels[i])) {
      _fields.put(labels[i],values[i]);
    }
 else {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + labels[i]);
    }
  }
}
Program: 76017
Project: 76017
Buggy source:
/** 
 * Constructor an with the specified container and name. This is protected because there is no reason to create an instance of this class, but derived classes will want to invoke the constructor of the superclass.
 * @param container The container.
 * @param name The name.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
protected DEActor(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the specified container and name. This is protected because there is no reason to create an instance of this class, but derived classes will want to invoke the constructor of the superclass.
 * @param container The container.
 * @param name The name.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
protected DEActor(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
}
Program: 76018
Project: 76018
Buggy source:
/** 
 * Return the earliest event in the queue without dequeueing it. This method is synchronized since there may be actors running under different threads in the DE domain.
 * @return The smallest event in the queue.
 * @exception InvalidStateException If the queue is empty.
 */
public synchronized final DEEvent get(){
  return (DEEvent)_cQueue.get();
}

Fixed version (ground truth):
/** 
 * Return the earliest event in the queue without removing the event from the queue. This method is synchronized since there may be actors running under different threads in the DE domain.
 * @return The smallest event in the queue.
 * @exception InvalidStateException If the queue is empty.
 */
public synchronized final DEEvent get(){
  return (DEEvent)_cQueue.get();
}
Program: 76019
Project: 76019
Buggy source:
/** 
 * Update the director parameters when the attributes are changed. Changes to <i>isCQAdaptive</i>, <i>minBinCount</i>, and <i>binCountFactor</i> parameters will only be effective on the next time the model is executed.
 * @param attr The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class. May be needed by derived classes.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (_debugging)   _debug("String_Node_Str",attribute.getName());
  if (attribute == stopWhenQueueIsEmpty) {
    _stopWhenQueueIsEmpty=((BooleanToken)stopWhenQueueIsEmpty.getToken()).booleanValue();
  }
  if (attribute == synchronizeToRealTime) {
    _synchronizeToRealTime=((BooleanToken)synchronizeToRealTime.getToken()).booleanValue();
  }
}

Fixed version (ground truth):
/** 
 * Update the director parameters when the attributes are changed. Changes to <i>isCQAdaptive</i>, <i>minBinCount</i>, and <i>binCountFactor</i> parameters will only be effective on the next time the model is executed.
 * @param attribute The changed parameter.
 * @exception IllegalActionException If the parameter set is not valid.Not thrown in this class. May be needed by derived classes.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (_debugging)   _debug("String_Node_Str",attribute.getName());
  if (attribute == stopWhenQueueIsEmpty) {
    _stopWhenQueueIsEmpty=((BooleanToken)stopWhenQueueIsEmpty.getToken()).booleanValue();
  }
  if (attribute == synchronizeToRealTime) {
    _synchronizeToRealTime=((BooleanToken)synchronizeToRealTime.getToken()).booleanValue();
  }
}
Program: 76022
Project: 76022
Buggy source:
/** 
 * Construct a DEIOPort with the specified container and name that is either an input, an output, or both, depending on the third and fourth arguments. The specified container must implement the Actor interface or an exception will be thrown.
 * @param container The container actor.
 * @param name The name of the port.
 * @param isinput True if this is to be an input port.
 * @param isoutput True if this is to be an output port.
 * @exception IllegalActionException If the port is not of an acceptableclass for the container, or if the container does not implement the Actor interface.
 * @exception NameDuplicationException If the name coincides witha port already in the container.
 */
public DEIOPort(ComponentEntity container,String name,boolean isinput,boolean isoutput) throws IllegalActionException, NameDuplicationException {
  super(container,name,isinput,isoutput);
}

Fixed version (ground truth):
/** 
 * Construct a DEIOPort with the specified container and name that is either an input, an output, or both, depending on the third and fourth arguments. The specified container must implement the Actor interface or an exception will be thrown.
 * @param container The container actor.
 * @param name The name of the port.
 * @param isInput True if this is to be an input port.
 * @param isOutput True if this is to be an output port.
 * @exception IllegalActionException If the port is not of an acceptableclass for the container, or if the container does not implement the Actor interface.
 * @exception NameDuplicationException If the name coincides witha port already in the container.
 */
public DEIOPort(ComponentEntity container,String name,boolean isInput,boolean isOutput) throws IllegalActionException, NameDuplicationException {
  super(container,name,isInput,isOutput);
}
Program: 76023
Project: 76023
Buggy source:
/** 
 * Send a token with the specified time delay to the receivers connected on the specified channel.  The time stamp of the token is equal to current time plus the specified delay. If the specified delay is zero, then the event is queued to be processed in the next microstep.
 * @param channelindex The index of the channel, from 0 to width-1.
 * @param token The token to send.
 * @param delay The time delay of the token being sent.
 * @exception IllegalActionException If the port is not an output,or if the index is out of range.
 */
public void send(int channelindex,Token token,double delay) throws IllegalActionException {
  _delay=delay;
  _useDelay=true;
  send(channelindex,token);
}

Fixed version (ground truth):
/** 
 * Send a token with the specified time delay to the receivers connected on the specified channel.  The time stamp of the token is equal to current time plus the specified delay. If the specified delay is zero, then the event is queued to be processed in the next microstep.
 * @param channelIndex The index of the channel, from 0 to width-1.
 * @param token The token to send.
 * @param delay The time delay of the token being sent.
 * @exception IllegalActionException If the port is not an output,or if the index is out of range.
 */
public void send(int channelIndex,Token token,double delay) throws IllegalActionException {
  _delay=delay;
  _useDelay=true;
  send(channelIndex,token);
}
Program: 76024
Project: 76024
Buggy source:
/** 
 * Get a token from the receiver.  The token returned is one that was put in the receiver with a time stamp equal to or earlier than the current time.  Note that there might be multiple such tokens in the receiver. In that case, FIFO behaviour is used with respect to the put() method. If there is no such token, throw an exception. This method is synhronized since the actor may not execute in the same thread as the director.
 * @return A token.
 * @exception NoTokenException If there are no more tokens. This isa runtime exception, so it need not be declared explicitly.
 */
public synchronized Token get() throws NoTokenException {
  if (_tokens.isEmpty()) {
    throw new NoTokenException(getContainer(),"String_Node_Str");
  }
  return (Token)_tokens.removeFirst();
}

Fixed version (ground truth):
/** 
 * Get a token from the receiver.  The token returned is one that was put in the receiver with a time stamp equal to or earlier than the current time.  Note that there might be multiple such tokens in the receiver. In that case, FIFO behaviour is used with respect to the put() method. If there is no such token, throw an exception. This method is synchronized since the actor may not execute in the same thread as the director.
 * @return A token.
 * @exception NoTokenException If there are no more tokens. This isa runtime exception, so it need not be declared explicitly.
 */
public synchronized Token get() throws NoTokenException {
  if (_tokens.isEmpty()) {
    throw new NoTokenException(getContainer(),"String_Node_Str");
  }
  return (Token)_tokens.removeFirst();
}
Program: 76025
Project: 76025
Buggy source:
/** 
 * Set the delay for the next call to put().  This causes the director to make the token available for the get() method at some future time, i.e. current time plus the specified delay.  This value of delay is only used in the next call to put(). If the specified delay is zero, then the next event is queued to be processed in the next microstep. This method is synhronized since the actor may not execute in the same thread as the director.
 * @param delay The delay.
 * @exception IllegalActionException If the delay is negative.
 */
public synchronized void setDelay(double delay) throws IllegalActionException {
  if (delay < 0.0) {
    throw new IllegalActionException(getContainer(),"String_Node_Str");
  }
  _delay=delay;
  _useDelay=true;
}

Fixed version (ground truth):
/** 
 * Set the delay for the next call to put().  This causes the director to make the token available for the get() method at some future time, i.e. current time plus the specified delay.  This value of delay is only used in the next call to put(). If the specified delay is zero, then the next event is queued to be processed in the next microstep. This method is synchronized since the actor may not execute in the same thread as the director.
 * @param delay The delay.
 * @exception IllegalActionException If the delay is negative.
 */
public synchronized void setDelay(double delay) throws IllegalActionException {
  if (delay < 0.0) {
    throw new IllegalActionException(getContainer(),"String_Node_Str");
  }
  _delay=delay;
  _useDelay=true;
}
Program: 76026
Project: 76026
Buggy source:
/** 
 * Put a token into this receiver with a future time stamp. This token will be available to the get() method at the time specified. Note that the time should be greater than or equal to the current time of the director, otherwise an exception will be thrown. This method is synhronized since the actor may not execute in the same thread as the director.
 * @param token The token to be put.
 * @param time The time stamp of the token
 * @exception IllegalActionException If time is less than thecurrent time of the director, or no director is available.
 */
public synchronized void put(Token token,double time) throws IllegalActionException {
  DEDirector dir=getDirector();
  double now=dir.getCurrentTime();
  if (time < now) {
    throw new IllegalActionException(getContainer(),"String_Node_Str");
  }
  if (time == now) {
    dir._enqueueEvent(this,token);
  }
 else {
    dir._enqueueEvent(this,token,time);
  }
}

Fixed version (ground truth):
/** 
 * Put a token into this receiver with a future time stamp. This token will be available to the get() method at the time specified. Note that the time should be greater than or equal to the current time of the director, otherwise an exception will be thrown. This method is synchronized since the actor may not execute in the same thread as the director.
 * @param token The token to be put.
 * @param time The time stamp of the token
 * @exception IllegalActionException If time is less than thecurrent time of the director, or no director is available.
 */
public synchronized void put(Token token,double time) throws IllegalActionException {
  DEDirector dir=getDirector();
  double now=dir.getCurrentTime();
  if (time < now) {
    throw new IllegalActionException(getContainer(),"String_Node_Str");
  }
  if (time == now) {
    dir._enqueueEvent(this,token);
  }
 else {
    dir._enqueueEvent(this,token,time);
  }
}
Program: 76027
Project: 76027
Buggy source:
private void _emptyPorts(){
  Iterator ports=inputPortList().iterator();
  while (ports.hasNext()) {
    IOPort port=(IOPort)ports.next();
    for (int ch=0; ch < port.getWidth(); ch++) {
      try {
        while (port.hasToken(ch)) {
          port.get(ch);
        }
      }
 catch (      IllegalActionException e) {
        e.printStackTrace();
        throw new InternalErrorException(e.getMessage());
      }
    }
  }
}

Fixed version (ground truth):
private void _emptyPorts(){
  Iterator ports=inputPortList().iterator();
  while (ports.hasNext()) {
    IOPort port=(IOPort)ports.next();
    for (int channel=0; channel < port.getWidth(); channel++) {
      try {
        while (port.hasToken(channel)) {
          port.get(channel);
        }
      }
 catch (      IllegalActionException e) {
        e.printStackTrace();
        throw new InternalErrorException(e.getMessage());
      }
    }
  }
}
Program: 76028
Project: 76028
Buggy source:
/** 
 * Queue a change request.  Delegate the change request to the container of this actor, if there is one.  If there is none, then delegate to the Manager.  If the actor has no manager then execute the request  immediately.  Any listeners that have been registered using addChangeListener() will be notified of success (or failure) of the request. <p> For the benefit of process-oriented domains, which may not have finite iterations, this method also calls stopFire() on the top-level composite actor, requesting that directors in such domains return from their fire() method (concluding the current iteration) as soon as practical, at which time the specified change will be executed.
 * @param change The requested change.
 */
public void requestChange(ChangeRequest change){
  CompositeEntity container=(CompositeEntity)getContainer();
  if (container == null) {
    Manager manager=getManager();
    if (manager == null) {
      change.setListeners(_changeListeners);
      change.execute();
    }
 else {
      manager.requestChange(change);
      stopFire();
    }
  }
 else {
    container.requestChange(change);
  }
}

Fixed version (ground truth):
/** 
 * Queue a change request.  Delegate the change request to the container of this actor, if there is one.  If there is none, then delegate to the Manager.  If the actor has no manager then execute the request  immediately.  Any listeners that have been registered using addChangeListener() will be notified of success (or failure) of the request. <p> For the benefit of process-oriented domains, which may not have finite iterations, this method also calls stopFire() on the top-level composite actor, requesting that directors in such domains return from their fire() method (concluding the current iteration) as soon as practical, at which time the specified change will be executed.
 * @param change The requested change.
 */
public void requestChange(ChangeRequest change){
  CompositeEntity container=(CompositeEntity)getContainer();
  if (container == null) {
    change.setListeners(_changeListeners);
    Manager manager=getManager();
    if (manager == null) {
      change.execute();
    }
 else {
      manager.requestChange(change);
    }
  }
 else {
    container.requestChange(change);
  }
}
Program: 76029
Project: 76029
Buggy source:
/** 
 * Queue a change request, or if the model is idle, execute it immediately.  If the request is queued, then it will be executed at the next opportunity, between top-level iterations of the model. Notify any change listeners when the change is executed.
 * @param change The requested change.
 */
public void requestChange(ChangeRequest change){
  change.setListeners(_changeListeners);
  if (_state == IDLE) {
    change.execute();
  }
 else {
    if (_changeRequests == null) {
      _changeRequests=new LinkedList();
    }
    _changeRequests.add(change);
  }
}

Fixed version (ground truth):
/** 
 * Queue a change request, or if the model is idle, execute it immediately.  If the request is queued, then it will be executed at the next opportunity, between top-level iterations of the model. Notify any change listeners when the change is executed.
 * @param change The requested change.
 */
public void requestChange(ChangeRequest change){
  if (_state == IDLE) {
    change.execute();
  }
 else {
    if (_changeRequests == null) {
      _changeRequests=new LinkedList();
    }
    _changeRequests.add(change);
    _container.stopFire();
  }
}
Program: 76032
Project: 76032
Buggy source:
/** 
 * Create a simple one-line text display, a non-editable value that is set externally using the setDisplay() method.
 * @param name The name used to identify the entry (when calling get).
 * @param label The label to attach to the entry.
 * @param theValue Default string to display.
 */
public void addDisplay(String name,String label,String theValue){
  JLabel lbl=new JLabel(label + "String_Node_Str");
  lbl.setBackground(_background);
  JTextArea displayField=new JTextArea(theValue,1,10);
  displayField.setEditable(false);
  displayField.setBackground(_background);
  _addPair(name,lbl,displayField);
}

Fixed version (ground truth):
/** 
 * Create a simple one-line text display, a non-editable value that is set externally using the setDisplay() method.
 * @param name The name used to identify the entry (when calling get).
 * @param label The label to attach to the entry.
 * @param theValue Default string to display.
 */
public void addDisplay(String name,String label,String theValue){
  JLabel lbl=new JLabel(label + "String_Node_Str");
  lbl.setBackground(_background);
  JTextArea displayField=new JTextArea(theValue,1,10);
  displayField.setEditable(false);
  displayField.setBackground(_background);
  _addPair(name,lbl,displayField,displayField);
}