nus-yam/ex-repair huggingface dataset:
Program: 75517
Project: 75517
Buggy source:
/** 
 * Get the output string to be sent. This does not return until a value is entered on the shell by the user.
 * @return The output string to be sent.
 */
public synchronized String getOutput(){
  while (_outputValues.size() < 1 && !_stopRequested) {
    try {
      wait();
    }
 catch (    InterruptedException ex) {
    }
  }
  if (_stopRequested) {
    return ("String_Node_Str");
  }
 else {
    return ((String)_outputValues.remove(0));
  }
}

Fixed version (ground truth):
/** 
 * Get the output string to be sent. This does not return until a value is entered on the shell by the user.
 * @return The output string to be sent.
 */
public synchronized String getOutput(){
  while (_outputValues.size() < 1 && !_stopRequested) {
    try {
      workspace().wait(this);
    }
 catch (    InterruptedException ex) {
    }
  }
  if (_stopRequested) {
    return ("String_Node_Str");
  }
 else {
    return ((String)_outputValues.remove(0));
  }
}
Program: 75518
Project: 75518
Buggy source:
/** 
 * Set the mode of parse tree evaluator to construction mode with mode as true, to update mode with mode as false.
 * @param mode The mode of the parse tree evaluator.
 */
public void setEvaluationMode(boolean mode){
  _construction=mode;
  if (mode) {
    _relationNumber=0;
    _relationIndex=0;
  }
}

Fixed version (ground truth):
/** 
 * Set the mode of parse tree evaluator.  If the given flag is true, then the relation list will be populated, based on the nodes in the parse tree.  If the given flag is false, then the list will simply be updated with new information
 * @param mode The mode of the parse tree evaluator.
 */
public void setEvaluationMode(boolean mode){
  _constructingRelationList=mode;
}
Program: 75519
Project: 75519
Buggy source:
/** 
 * Construct a parse tree evaluator for guard expression. The relation list is used to store the information of the relation nodes and leaf nodes with boolean tokens. If the relation list is empty, the evaluator is in construction mode, otherwise, it is in update mode.
 * @param relationList The relation list.
 * @param errorTolerance The errorTolerance.
 */
public ParseTreeEvaluatorForGuardExpression(RelationList relationList,double errorTolerance){
  if (relationList.isEmpty()) {
    _construction=true;
  }
 else {
    _construction=false;
  }
  _relationList=relationList;
  _relationIndex=0;
  _relationNumber=0;
  _absentDiscreteVariables=new LinkedList();
  _errorTolerance=errorTolerance;
  _variableCollector=new ParseTreeFreeVariableCollector();
}

Fixed version (ground truth):
/** 
 * Construct a parse tree evaluator for guard expression. The relation list is used to store the information of the relation nodes and leaf nodes with boolean tokens. If the relation list is empty, the evaluator is in construction mode, otherwise, it is in update mode.
 * @param relationList The relation list.
 * @param errorTolerance The errorTolerance.
 */
public ParseTreeEvaluatorForGuardExpression(RelationList relationList,double errorTolerance){
  if (relationList.isEmpty()) {
    _constructingRelationList=true;
  }
 else {
    _constructingRelationList=false;
  }
  _relationList=relationList;
  _relationIndex=0;
  _absentDiscreteVariables=new LinkedList();
  _errorTolerance=errorTolerance;
  _variableCollector=new ParseTreeFreeVariableCollector();
}
Program: 75522
Project: 75522
Buggy source:
/** 
 * Update the model here to achieve consistency.
 * @exception IllegalActionException If there is no director,or if the director's postfire() method throws it, or if this actor is not opaque.
 */
public boolean postfire() throws IllegalActionException {
  if (!_stopRequested && _model != null) {
    String delete=_requestToRemoveAll(this);
    MoMLChangeRequest removeRequest=new MoMLChangeRequest(this,this,delete,null);
    requestChange(removeRequest);
    MoMLChangeRequest request=new MoMLChangeRequest(this,this,_model.exportMoML(),null);
    requestChange(request);
    String moml="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + _model.getName() + "String_Node_Str"+ "String_Node_Str"+ _model.getName()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    MoMLChangeRequest request2=new MoMLChangeRequest(this,this,moml,null);
    requestChange(request2);
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _model=null;
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Update the model here to achieve consistency.
 * @exception IllegalActionException If there is no director,or if the director's postfire() method throws it, or if this actor is not opaque.
 */
public boolean postfire() throws IllegalActionException {
  if (!_stopRequested && _model != null) {
    String delete=_requestToRemoveAll(this);
    MoMLChangeRequest removeRequest=new MoMLChangeRequest(this,this,delete,null);
    requestChange(removeRequest);
    StringWriter writer=new StringWriter();
    try {
      _model.exportMoML(writer,1);
    }
 catch (    Exception ex) {
    }
    String modelMoML=writer.toString();
    String moml="String_Node_Str" + modelMoML + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ _model.getName()+ "String_Node_Str"+ "String_Node_Str"+ _model.getName()+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    System.out.println("String_Node_Str" + moml);
    MoMLChangeRequest request2=new MoMLChangeRequest(this,this,moml,null);
    requestChange(request2);
    if (_debugging) {
      _debug("String_Node_Str");
    }
    _model=null;
  }
  return super.postfire();
}
Program: 75523
Project: 75523
Buggy source:
/** 
 * Return true if the actor either of its input port has token.
 * @exception IllegalActionException Not thrown in this base class.
 */
public boolean prefire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  if (input.hasToken(0) || modelString.hasToken(0)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Return true if the actor either of its input port has token.
 * @exception IllegalActionException Not thrown in this base class.
 */
public boolean prefire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  if (input.hasToken(0) || modelString.hasToken(0)) {
    return super.prefire();
  }
  return false;
}
Program: 75524
Project: 75524
Buggy source:
/** 
 * Initialize this actor. create a new moml parser for passing the applied model to it.
 * @exception IllegalActionException If there is no director, orif the director's initialize() method throws it, or if the actor is not opaque.
 */
public void initialize() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  _model=null;
  try {
    _parser=new MoMLParser();
    _parser.setMoMLFilters(BackwardCompatibility.allFilters());
    _parser.addMoMLFilter(new RemoveGraphicalClasses());
    Const constActor=new Const(this,"String_Node_Str");
    constActor.value.setExpression(defaultValue.getToken().toString());
    connect(input,constActor.trigger);
    connect(constActor.output,output);
  }
 catch (  Exception ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
  super.initialize();
}

Fixed version (ground truth):
/** 
 * Initialize this actor. create a new moml parser for passing the applied model to it.
 * @exception IllegalActionException If there is no director, orif the director's initialize() method throws it, or if the actor is not opaque.
 */
public void initialize() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  _model=null;
  try {
    _parser=new MoMLParser();
    _parser.setMoMLFilters(BackwardCompatibility.allFilters());
    Const constActor=new Const(this,"String_Node_Str");
    constActor.value.setExpression(defaultValue.getToken().toString());
    connect(input,constActor.trigger);
    connect(constActor.output,output);
  }
 catch (  Exception ex) {
    throw new IllegalActionException(this,ex,"String_Node_Str");
  }
  super.initialize();
}
Program: 75525
Project: 75525
Buggy source:
/** 
 * Construct an actor with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the container is incompatiblewith this actor.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public MobileModel(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  modelString=new TypedIOPort(this,"String_Node_Str",true,false);
  modelString.setTypeEquals(BaseType.STRING);
  defaultValue=new Parameter(this,"String_Node_Str",new IntToken(0));
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeAtLeast(defaultValue);
  new Director(this,"String_Node_Str");
  getMoMLInfo().className="String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Construct an actor with a name and a container. The container argument must not be null, or a NullPointerException will be thrown.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the container is incompatiblewith this actor.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public MobileModel(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  modelString=new TypedIOPort(this,"String_Node_Str",true,false);
  modelString.setTypeEquals(BaseType.STRING);
  defaultValue=new Parameter(this,"String_Node_Str",new IntToken(0));
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeAtLeast(defaultValue);
  new DEDirector(this,"String_Node_Str");
  getMoMLInfo().className="String_Node_Str";
}
Program: 75528
Project: 75528
Buggy source:
/** 
 * If the string is longer than 79 characters, split it up by displaying adding newlines in all newline delimited substrings that are longer than 79 characters.  If the <i>longName</i> argument is null, then the string "<Unnamed>" is returned.
 * @see #abbreviate(String longName)
 * @param longName The string to optionally split up
 * @return Either the original string, or the string with newlinesinserted
 */
public static String split(String longName){
  if (longName == null) {
    return "String_Node_Str";
  }
  if (longName.length() < 80) {
    return longName;
  }
  StringBuffer results=new StringBuffer();
  StringTokenizer tokenizer=new StringTokenizer(longName,"String_Node_Str",true);
  while (tokenizer.hasMoreTokens()) {
    String token=tokenizer.nextToken();
    int i=0;
    while (i < token.length() - 79) {
      int lastSpaceIndex=token.substring(i,i + 79).lastIndexOf("String_Node_Str");
      if (lastSpaceIndex < 0) {
        results.append(token.substring(i,i + 79) + "String_Node_Str");
        i+=79;
      }
 else {
        results.append(token.substring(i,lastSpaceIndex) + "String_Node_Str");
        i=lastSpaceIndex + 1;
      }
    }
    results.append(token.substring(i));
  }
  return results.toString();
}

Fixed version (ground truth):
/** 
 * If the string is longer than 79 characters, split it up by displaying adding newlines in all newline delimited substrings that are longer than 79 characters.  If the <i>longName</i> argument is null, then the string "<Unnamed>" is returned.
 * @see #abbreviate(String longName)
 * @param longName The string to optionally split up
 * @return Either the original string, or the string with newlinesinserted
 */
public static String split(String longName){
  if (longName == null) {
    return "String_Node_Str";
  }
  if (longName.length() < 80) {
    return longName;
  }
  StringBuffer results=new StringBuffer();
  StringTokenizer tokenizer=new StringTokenizer(longName,"String_Node_Str",true);
  while (tokenizer.hasMoreTokens()) {
    String token=tokenizer.nextToken();
    int i=0;
    while (i < token.length() - 79) {
      int lastSpaceIndex=token.substring(i,i + 79).lastIndexOf("String_Node_Str");
      if (lastSpaceIndex < 0) {
        results.append(token.substring(i,i + 79) + "String_Node_Str");
        i+=79;
      }
 else {
        results.append(token.substring(i,i + lastSpaceIndex) + "String_Node_Str");
        i+=lastSpaceIndex + 1;
      }
    }
    results.append(token.substring(i));
  }
  return results.toString();
}
Program: 75529
Project: 75529
Buggy source:
/** 
 * Check whether the current director is a GRDirector. If not, throw an illegal action exception.
 * @exception IllegalActionException If the current directoris not a GRDirector.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
}

Fixed version (ground truth):
/** 
 * Check whether the current director is a GRDirector. If not, throw an illegal action exception.
 * @exception IllegalActionException If the current directoris not a GRDirector.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _isSceneGraphInitialized=false;
}
Program: 75530
Project: 75530
Buggy source:
/** 
 * Initialize all the actors associated with this director. Perform some internal initialization for this director.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _buildActorTable();
  _iteration=0;
}

Fixed version (ground truth):
/** 
 * Initialize all the actors associated with this director. Perform some internal initialization for this director.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _buildActorTable();
  _iteration=0;
  TypedCompositeActor container=(TypedCompositeActor)getContainer();
  List viewScreens=container.entityList(ViewScreen.class);
  if (viewScreens.size() != 1) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  ViewScreen viewScreen=(ViewScreen)viewScreens.get(0);
  for (Iterator actors=container.entityList(GRActor.class).iterator(); actors.hasNext(); ) {
    GRActor actor=(GRActor)actors.next();
    actor._setViewScreen(viewScreen);
  }
}
Program: 75532
Project: 75532
Buggy source:
protected void _makeSceneGraphConnection() throws IllegalActionException {
  if (_root == null) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    ViewScreen viewScreen=(ViewScreen)_root;
    viewScreen.addChild(_getNodeObject());
  }
}

Fixed version (ground truth):
protected void _makeSceneGraphConnection() throws IllegalActionException {
  if (_viewScreen == null) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    _viewScreen.addChild(_getNodeObject());
  }
}
Program: 75533
Project: 75533
Buggy source:
protected void _makeSceneGraphConnection() throws IllegalActionException {
  if (_root == null) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    ViewScreen viewScreen=(ViewScreen)_root;
    viewScreen.addChild(_getNodeObject());
  }
}

Fixed version (ground truth):
protected void _makeSceneGraphConnection() throws IllegalActionException {
  if (_viewScreen == null) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    _viewScreen.addChild(_getNodeObject());
  }
}
Program: 75534
Project: 75534
Buggy source:
public MouseInput3D(TypedCompositeActor container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  x=new TypedIOPort(this,"String_Node_Str");
  x.setOutput(true);
  x.setTypeEquals(BaseType.INT);
  y=new TypedIOPort(this,"String_Node_Str");
  y.setOutput(true);
  y.setTypeEquals(BaseType.INT);
}

Fixed version (ground truth):
public MouseInput3D(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  x=new TypedIOPort(this,"String_Node_Str");
  x.setOutput(true);
  x.setTypeEquals(BaseType.INT);
  y=new TypedIOPort(this,"String_Node_Str");
  y.setOutput(true);
  y.setTypeEquals(BaseType.INT);
}
Program: 75536
Project: 75536
Buggy source:
/** 
 * Add the node argument as a child to the encapsulated Java3D node in this actor.
 */
protected void addChild(Node node){
  _addChild(node);
}

Fixed version (ground truth):
/** 
 * Add the node argument as a child to the encapsulated Java3D node in this actor.
 */
public void addChild(Node node){
  _addChild(node);
}
Program: 75538
Project: 75538
Buggy source:
public static ArrayToken map(FunctionToken function,ArrayToken array){
  int num=function.getNumberOfArguments();
  ArrayToken result=null;
  if (BaseType.SCALAR.isCompatible(array.getElementType())) {
    if (num != 1) {
      throw new IllegalActionException("String_Node_Str");
    }
 else {
      for (int i=0; i < array.length(); i++) {
        ScalarToken args=(ScalarToken)array.getElement(i);
        LinkedList arglist=new LinkedList();
        arglist.add(args);
        result.add(function.apply(arglist));
      }
    }
  }
 else {
    for (int i=0; i < array.length(); i++) {
      ArrayToken args=(ArrayToken)array.getElement(i);
      LinkedList arglist=new LinkedList();
      if (args.length() != num) {
        throw new IllegalActionException("String_Node_Str");
      }
 else {
        for (int j=1; j < num; j++) {
          arglist.add(args.getElement(j));
        }
        result.add(function.apply(arglist));
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Apply the specified function to the specified array and return an array with the results. The function must take at least one argument. If the function takes more than one argument, then the specified array should be an array of arrays, where each subarray is a set of arguments.  Since arrays in the expression language can only contain elements of the same type, this method will only work for functions whose arguments are all of the same type.
 * @param function A function with at least one argument.
 * @param array The array to which to apply the function.
 * @return A new array that is the result of applying the functionto the specified array.
 * @exception IllegalActionException If the specified function does nottake at least one argument, or if an error occurs applying the function, or if the number of arguments does not match the subarray lengths.
 */
public static ArrayToken map(FunctionToken function,ArrayToken array) throws IllegalActionException {
  int arity=function.getNumberOfArguments();
  ArrayToken result=null;
  if (BaseType.SCALAR.isCompatible(array.getElementType())) {
    if (arity != 1) {
      throw new IllegalActionException("String_Node_Str");
    }
 else {
      for (int i=0; i < array.length(); i++) {
        ScalarToken args=(ScalarToken)array.getElement(i);
        LinkedList arglist=new LinkedList();
        arglist.add(args);
        result.add(function.apply(arglist));
      }
    }
  }
 else {
    for (int i=0; i < array.length(); i++) {
      ArrayToken args=(ArrayToken)array.getElement(i);
      LinkedList arglist=new LinkedList();
      if (args.length() != arity) {
        throw new IllegalActionException("String_Node_Str");
      }
 else {
        for (int j=1; j < arity; j++) {
          arglist.add(args.getElement(j));
        }
        result.add(function.apply(arglist));
      }
    }
  }
  return result;
}
Program: 75539
Project: 75539
Buggy source:
public ArrayToken iterate(FunctionToken function,int length,Token initValue){
  int num=function.getNumberOfArguments();
  ArrayToken result=null;
  if (num != 1) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    result.add(initValue);
    Token iterate=initValue;
    for (int i=0; i < length; i++) {
      LinkedList arglist=new LinkedList();
      arglist.add(iterate);
      iterate=function.apply(arglist);
      result.add(iterate);
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Iterate the specified function to produce an array of the specified length.  The first element of the output array is the <i>initial</i> argument, the second is the result of applying the function to <i>initial</i>, the third is the result of applying the function to that result, etc.
 * @param function A single-argument function to iterate.
 * @param length The length of the resulting array.
 * @param initial The first element of the result.
 * @return A new array that is the result of applying the functionrepeatedly.
 * @exception IllegalActionException If the specified function does nottake exactly one argument, or if an error occurs applying the function.
 */
public ArrayToken iterate(FunctionToken function,int length,Token initial) throws IllegalActionException {
  int arity=function.getNumberOfArguments();
  if (arity != 1) {
    throw new IllegalActionException("String_Node_Str");
  }
 else {
    ArrayToken result=null;
    Token iterate=initial;
    result.add(iterate);
    for (int i=1; i < length; i++) {
      LinkedList arglist=new LinkedList();
      arglist.add(iterate);
      iterate=function.apply(arglist);
    }
    return result;
  }
}
Program: 75540
Project: 75540
Buggy source:
/** 
 * Test that the value of this token is close to the first argument, where "close" means that the distance between their values is less than or equal to the second argument. It is assumed that the type of the first argument is DoubleToken.
 * @param token The token to compare to this token.
 * @return A token containing true if the value of this token is closeto that of the argument.
 */
protected BooleanToken _isCloseTo(ScalarToken rightArgument,double epsilon){
  return BooleanToken.getInstance(Math.abs(doubleValue() - ((DoubleToken)rightArgument).doubleValue()) <= epsilon);
}

Fixed version (ground truth):
/** 
 * Test that the value of this token is close to the first argument, where "close" means that the distance between their values is less than or equal to the second argument. It is assumed that the type of the first argument is DoubleToken.
 * @param token The token to compare to this token.
 * @return A token containing true if the value of this token is closeto that of the argument.
 */
protected BooleanToken _isCloseTo(ScalarToken rightArgument,double epsilon){
  double right=((DoubleToken)rightArgument).doubleValue();
  double left=doubleValue();
  if (right > left + epsilon || right < left - epsilon) {
    return BooleanToken.FALSE;
  }
 else {
    return BooleanToken.TRUE;
  }
}
Program: 75541
Project: 75541
Buggy source:
/** 
 * Indicate that the calling thread is finished writing. This wakes up any threads that are suspended on access to this workspace so that they may contend for permissions. It also increments the version number of the workspace.
 * @exception InvalidStateException If this method is called whenthe workspace is read-only.
 */
public final synchronized void doneWriting(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (current != _writer) {
    if (record != null && record.failedWriteAttempts > 0) {
      record.failedWriteAttempts--;
    }
 else {
      throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
 else {
    if (_writeDepth > 0) {
      _writeReq--;
      _writeDepth--;
      if (_writeDepth == 0) {
        _writer=null;
        incrVersion();
        notifyAll();
      }
    }
 else {
      throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Indicate that the calling thread is finished writing. This wakes up any threads that are suspended on access to this workspace so that they may contend for permissions. It also increments the version number of the workspace.
 * @exception InvalidStateException If this method is called whenthe workspace is read-only.
 */
public final synchronized void doneWriting(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (current != _writer) {
    if (record != null && record.failedWriteAttempts > 0) {
      record.failedWriteAttempts--;
    }
 else {
      throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
 else {
    if (_writeDepth > 0) {
      _writeDepth--;
      if (_writeDepth == 0) {
        _writer=null;
        incrVersion();
        notifyAll();
      }
    }
 else {
      throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
}
Program: 75542
Project: 75542
Buggy source:
/** 
 * Obtain permissions to read objects in the workspace. This obtains many permissions on the read access and should be called in conjunction with _releaseAllReadPermissions. This method suspends the calling thread until such permission has been obtained.  Permission is granted unless either another thread has write permission, or there are threads that have requested write permission and not gotten it yet.
 * @param count This is the number of read permissions desired on theworkspace.
 */
private synchronized void _reacquireReadPermissions(int count){
  if (count == 0)   return;
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (record == null || count > record.failedReadAttempts) {
    throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
  }
  while (true) {
    if (current == _writer || _writeReq == 0) {
      _numReaders++;
      record.failedReadAttempts-=count;
      record.readDepth=count;
      return;
    }
    try {
      wait();
    }
 catch (    InterruptedException ex) {
      throw new InternalErrorException("String_Node_Str" + ex.getMessage());
    }
  }
}

Fixed version (ground truth):
/** 
 * Obtain permissions to read objects in the workspace. This obtains many permissions on the read access and should be called in conjunction with _releaseAllReadPermissions. This method suspends the calling thread until such permission has been obtained.  Permission is granted unless either another thread has write permission, or there are threads that have requested write permission and not gotten it yet.
 * @param count This is the number of read permissions desired on theworkspace.
 */
private synchronized void _reacquireReadPermissions(int count){
  if (count == 0)   return;
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (record == null || count > record.failedReadAttempts) {
    throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
  }
  while (true) {
    if (current == _writer || (_writeReq == 0 && _writer == null)) {
      _numReaders++;
      record.failedReadAttempts-=count;
      record.readDepth=count;
      return;
    }
    try {
      wait();
    }
 catch (    InterruptedException ex) {
      throw new InternalErrorException("String_Node_Str" + ex.getMessage());
    }
  }
}
Program: 75543
Project: 75543
Buggy source:
/** 
 * Obtain permission to read objects in the workspace. This method suspends the calling thread until such permission has been obtained.  Permission is granted unless either another thread has write permission, or there are threads that have requested write permission and not gotten it yet. If this thread already has a read permission, then another permission is granted irrespective of other write requests. It is essential that doneReading() be called after this, or write permission may never again be granted in this workspace. If the workspace is read-only, the calling thread will not suspend, and will just return immediately from the method call. The pairing between the getReadAccess() and doneReading() methods is not checked under this condition.
 */
public final synchronized void getReadAccess(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,true);
  }
  if (record.readDepth > 0) {
    record.readDepth++;
    return;
  }
 else   if (current == _writer) {
    record.readDepth++;
    _numReaders++;
    return;
  }
  record.failedReadAttempts++;
  while (_writeReq != 0) {
    try {
      wait(this);
    }
 catch (    InterruptedException ex) {
      throw new InternalErrorException(current.getName() + "String_Node_Str" + "String_Node_Str"+ ex.getMessage());
    }
  }
  record.failedReadAttempts--;
  record.readDepth++;
  _numReaders++;
  return;
}

Fixed version (ground truth):
/** 
 * Obtain permission to read objects in the workspace. This method suspends the calling thread until such permission has been obtained.  Permission is granted unless either another thread has write permission, or there are threads that have requested write permission and not gotten it yet. If this thread already has a read permission, then another permission is granted irrespective of other write requests. It is essential that doneReading() be called after this, or write permission may never again be granted in this workspace. If the workspace is read-only, the calling thread will not suspend, and will just return immediately from the method call. The pairing between the getReadAccess() and doneReading() methods is not checked under this condition.
 */
public final synchronized void getReadAccess(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,true);
  }
  if (record.readDepth > 0) {
    record.readDepth++;
    return;
  }
 else   if (current == _writer) {
    record.readDepth++;
    _numReaders++;
    return;
  }
  record.failedReadAttempts++;
  while (_writeReq != 0 || _writer != null) {
    try {
      wait();
    }
 catch (    InterruptedException ex) {
      throw new InternalErrorException(current.getName() + "String_Node_Str" + "String_Node_Str"+ ex.getMessage());
    }
  }
  record.failedReadAttempts--;
  record.readDepth++;
  _numReaders++;
  return;
}
Program: 75544
Project: 75544
Buggy source:
/** 
 * Indicate that the calling thread is finished reading. If this thread is completely done reading (it has no other active read or write permissions), then wake up any threads that are suspended on access to this workspace so that they may contend for permissions. If the workspace is read-only, the pairing between the getReadAccess() and doneReading() methods is not checked.
 * @exception InvalidStateException If this method is calledbefore a corresponding call to getReadAccess().
 */
public final synchronized void doneReading(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (record == null) {
    throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
  }
  if (record.readDepth > 0) {
    record.readDepth--;
    if (record.readDepth == 0) {
      _numReaders--;
      if (_numReaders == 0) {
        notifyAll();
      }
    }
  }
 else   if (record.failedReadAttempts > 0) {
    record.failedReadAttempts--;
  }
 else {
    throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Indicate that the calling thread is finished reading. If this thread is completely done reading (it has no other active read or write permissions), then wake up any threads that are suspended on access to this workspace so that they may contend for permissions. If the workspace is read-only, the pairing between the getReadAccess() and doneReading() methods is not checked.
 * @exception InvalidStateException If this method is calledbefore a corresponding call to getReadAccess().
 */
public final synchronized void doneReading(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (record == null) {
    throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
  }
  if (record.readDepth > 0) {
    record.readDepth--;
    if (record.readDepth == 0) {
      _numReaders--;
      notifyAll();
    }
  }
 else   if (record.failedReadAttempts > 0) {
    record.failedReadAttempts--;
  }
 else {
    throw new InvalidStateException(this,"String_Node_Str" + "String_Node_Str");
  }
}
Program: 75545
Project: 75545
Buggy source:
/** 
 * Frees the thread of all the readAccesses on the workspace. The method _reacquireAllReadAccesses should be called after this method is called.
 * @return The number of readAccess that the thread possessed on theworkspace
 */
private synchronized int _releaseAllReadPermissions(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (record == null || record.readDepth == 0) {
    return 0;
  }
 else {
    _numReaders--;
    if (_numReaders == 0) {
      notifyAll();
    }
    int result=record.readDepth;
    record.failedReadAttempts+=result;
    record.readDepth=0;
    return result;
  }
}

Fixed version (ground truth):
/** 
 * Frees the thread of all the readAccesses on the workspace. The method _reacquireAllReadAccesses should be called after this method is called.
 * @return The number of readAccess that the thread possessed on theworkspace
 */
private synchronized int _releaseAllReadPermissions(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,false);
  }
  if (record == null || record.readDepth == 0) {
    return 0;
  }
 else {
    _numReaders--;
    notifyAll();
    int result=record.readDepth;
    record.failedReadAttempts+=result;
    record.readDepth=0;
    return result;
  }
}
Program: 75546
Project: 75546
Buggy source:
/** 
 * Obtain permission to write to objects in the workspace. Permission is granted if there are no other threads that currently have read or write permission.  In particular, it <i>is</i> granted if this thread already has write permission, or if it is the only thread with read permission. This method suspends the calling thread until such permission has been obtained.  It is essential that doneWriting() be called after this, or read or write permission may never again be granted in this workspace.
 * @exception InvalidStateException If this method is called when theworkspace is read-only.
 */
public final synchronized void getWriteAccess(){
  Thread current=Thread.currentThread();
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,true);
  }
  _writeReq++;
  if (current == _writer) {
    _writeDepth++;
    return;
  }
  record.failedWriteAttempts++;
  while (true) {
    if (_writer == null) {
      if (_numReaders == 0) {
        _writer=current;
        _writeDepth=1;
        record.failedWriteAttempts--;
        return;
      }
 else       if (_numReaders == 1) {
        if (record != null && record.readDepth > 0) {
          _writer=current;
          _writeDepth=1;
          record.failedWriteAttempts--;
          return;
        }
      }
    }
    try {
      wait();
    }
 catch (    InterruptedException ex) {
      _writeReq--;
      throw new InternalErrorException(current.getName() + "String_Node_Str" + "String_Node_Str"+ ex.getMessage());
    }
  }
}

Fixed version (ground truth):
/** 
 * Obtain permission to write to objects in the workspace. Permission is granted if there are no other threads that currently have read or write permission.  In particular, it <i>is</i> granted if this thread already has write permission, or if it is the only thread with read permission. This method suspends the calling thread until such permission has been obtained.  It is essential that doneWriting() be called after this, or read or write permission may never again be granted in this workspace.
 * @exception InvalidStateException If this method is called when theworkspace is read-only.
 */
public final synchronized void getWriteAccess(){
  Thread current=Thread.currentThread();
  if (current == _writer) {
    _writeDepth++;
    return;
  }
  AccessRecord record=null;
  if (current == _lastReader) {
    record=_lastReaderRecord;
  }
 else {
    record=_getAccessRecord(current,true);
  }
  _writeReq++;
  record.failedWriteAttempts++;
  try {
    while (true) {
      if (_writer == null) {
        if (_numReaders == 0 || _numReaders == 1 && record.readDepth > 0) {
          _writer=current;
          _writeDepth=1;
          record.failedWriteAttempts--;
          return;
        }
      }
      try {
        wait();
      }
 catch (      InterruptedException ex) {
        throw new InternalErrorException(current.getName() + "String_Node_Str" + "String_Node_Str"+ ex.getMessage());
      }
    }
  }
  finally {
    _writeReq--;
    if (_writeReq == 0 && _writer == null) {
      notifyAll();
    }
  }
}
Program: 75547
Project: 75547
Buggy source:
/** 
 * Returns the C filename corresponding to a class.
 * @param className The name of a class.
 * @return The C fileName corresponding to this class.
 */
public static String classNameToFileName(String className){
  if (isSystemClass(className)) {
    return (Options.v().get("String_Node_Str") + "String_Node_Str" + _sanitize(className).replace('.','/'));
  }
 else {
    return (_sanitize(className));
  }
}

Fixed version (ground truth):
/** 
 * Returns the C filename corresponding to a class.
 * @param className The name of a class.
 * @return The C fileName corresponding to this class.
 */
public static String classNameToFileName(String className){
  if (isSystemClass(className)) {
    return (Options.v().get("String_Node_Str") + "String_Node_Str" + _sanitize(className).replace('.','/'));
  }
 else {
    return (_sanitize(className).replace('.','/'));
  }
}
Program: 75550
Project: 75550
Buggy source:
public void event(String actorName,double time,int scheduleEvent){
  try {
    if (scheduleEvent == -1) {
      if (plot != null) {
        plot.clear(true);
        _taskMap.clear();
        _taskState.clear();
      }
    }
 else {
      if (_taskMap != null) {
        Object taskID=_taskMap.get(actorName);
        int id;
        if (taskID == null) {
          id=_taskMap.size();
          _taskMap.put(actorName,new Integer(id));
          _taskState.add(new Integer(0));
          plot.addLegend(id,actorName);
        }
 else {
          id=((Integer)taskID).intValue();
        }
        int _oldState=((Integer)_taskState.get(id)).intValue();
        plot.addPoint(id,time,id + _oldState / 2.1,true);
        plot.addPoint(id,time,id + scheduleEvent / 2.1,true);
        plot.repaint();
        _taskState.set(id,new Integer(scheduleEvent));
      }
    }
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e);
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void event(final String actorName,double time,int scheduleEvent){
  try {
    if (scheduleEvent == -1) {
      if (plot != null) {
        plot.clear(true);
        _taskMap.clear();
        _taskState.clear();
        System.out.println("String_Node_Str");
      }
    }
 else {
      if (_taskMap != null) {
        Object taskID=_taskMap.get(actorName);
        int id;
        if (taskID == null) {
          id=_taskMap.size();
          final int finalid=id;
          _taskMap.put(actorName,new Integer(id));
          _taskState.add(new Integer(0));
          System.out.println("String_Node_Str");
          Runnable doAddPoint=new Runnable(){
            public void run(){
              plot.addLegend(finalid,actorName);
            }
          }
;
          plot.deferIfNecessary(doAddPoint);
        }
 else {
          id=((Integer)taskID).intValue();
        }
        int _oldState=((Integer)_taskState.get(id)).intValue();
        plot.addPoint(id,time,id + _oldState / 2.1,true);
        plot.addPoint(id,time,id + scheduleEvent / 2.1,true);
        _taskState.set(id,new Integer(scheduleEvent));
        plot.repaint();
      }
    }
  }
 catch (  Exception e) {
    System.out.println("String_Node_Str" + e);
    e.printStackTrace();
  }
}
Program: 75552
Project: 75552
Buggy source:
/** 
 * Specify whether this workspace is read only. When the workspace is read only, calling getWriteAccess() or doneWriting() will result in a runtime exception, and calling getReadAccess() and doneReading() will return immediately. Accesses to topology information are considerably more efficient if the workspace is read only.
 * @param flagValue True to make the workspace read only, and falseotherwise.
 * @exception IllegalActionException If a thread has writeaccess on the workspace.
 */
public synchronized void setReadOnly(boolean flagValue) throws IllegalActionException {
  if (flagValue == true) {
    if (_writer != null) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
  _readOnly=flagValue;
}

Fixed version (ground truth):
/** 
 * Specify whether this workspace is read only. When the workspace is read only, calling getWriteAccess() or doneWriting() will result in a runtime exception, and calling getReadAccess() and doneReading() will return immediately. Accesses to topology information are considerably more efficient if the workspace is read only.
 * @param flagValue True to make the workspace read only, and falseotherwise.
 * @exception IllegalActionException If a thread has writeaccess on the workspace.
 */
public synchronized void setReadOnly(boolean flagValue) throws IllegalActionException {
  if (flagValue == true) {
    if (_writer != null || (_readers.isEmpty() && _numPtReaders == 0)) {
      throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str");
    }
  }
  _readOnly=flagValue;
}
Program: 75553
Project: 75553
Buggy source:
/** 
 * Initialize this display.  If place() has not been called with a container into which to place the display, then create a new frame into which to put it.
 * @exception IllegalActionException If the parent class throws it,or if the numRows or numColumns parameters are incorrect, or if there is no effigy for the top level container, or if a problem occurs creating the effigy and tableau.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (textArea == null) {
    Effigy containerEffigy=Configuration.findEffigy(toplevel());
    if (containerEffigy == null) {
      throw new IllegalActionException(this,"String_Node_Str" + toplevel().getFullName());
    }
    try {
      TextEffigy textEffigy=TextEffigy.newTextEffigy(containerEffigy,"String_Node_Str");
      textEffigy.identifier.setExpression(getFullName());
      DisplayWindowTableau tableau=new DisplayWindowTableau(textEffigy,"String_Node_Str");
      _frame=tableau.frame;
    }
 catch (    Exception ex) {
      throw new IllegalActionException(this,null,ex,"String_Node_Str");
    }
    textArea=_frame.text;
    int numRows=((IntToken)rowsDisplayed.getToken()).intValue();
    textArea.setRows(numRows);
    int numColumns=((IntToken)columnsDisplayed.getToken()).intValue();
    textArea.setColumns(numColumns);
    _windowProperties.setProperties(_frame);
  }
 else {
    textArea.setText(null);
  }
  if (_frame != null) {
    _frame.show();
  }
}

Fixed version (ground truth):
/** 
 * Initialize this display.  If place() has not been called with a container into which to place the display, then create a new frame into which to put it.
 * @exception IllegalActionException If the parent class throws it,or if the numRows or numColumns parameters are incorrect, or if there is no effigy for the top level container, or if a problem occurs creating the effigy and tableau.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  if (textArea == null) {
    Effigy containerEffigy=Configuration.findEffigy(toplevel());
    if (containerEffigy == null) {
      throw new IllegalActionException(this,"String_Node_Str" + toplevel().getFullName());
    }
    try {
      TextEffigy textEffigy=TextEffigy.newTextEffigy(containerEffigy,"String_Node_Str");
      textEffigy.identifier.setExpression(getFullName());
      DisplayWindowTableau tableau=new DisplayWindowTableau(textEffigy,"String_Node_Str");
      _frame=tableau.frame;
    }
 catch (    Exception ex) {
      throw new IllegalActionException(this,null,ex,"String_Node_Str");
    }
    textArea=_frame.text;
    int numRows=((IntToken)rowsDisplayed.getToken()).intValue();
    textArea.setRows(numRows);
    int numColumns=((IntToken)columnsDisplayed.getToken()).intValue();
    textArea.setColumns(numColumns);
    _windowProperties.setProperties(_frame);
    _frame.show();
  }
 else {
    textArea.setText(null);
  }
}
Program: 75554
Project: 75554
Buggy source:
/** 
 * Override the base class to remove the display from its graphical container if the argument is null.
 * @param container The proposed container.
 * @exception IllegalActionException If the base class throws it.
 * @exception NameDuplicationException If the base class throws it.
 */
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  Nameable previousContainer=getContainer();
  super.setContainer(container);
  if (container != previousContainer) {
    _remove();
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to remove the display from its graphical container if the argument is null.
 * @param container The proposed container.
 * @exception IllegalActionException If the base class throws it.
 * @exception NameDuplicationException If the base class throws it.
 */
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  Nameable previousContainer=getContainer();
  super.setContainer(container);
  if (container != previousContainer && previousContainer != null) {
    _remove();
  }
}
Program: 75555
Project: 75555
Buggy source:
/** 
 * Override the base class to remove the plot from its graphical container if the argument is null.
 * @param container The proposed container.
 * @exception IllegalActionException If the base class throws it.
 * @exception NameDuplicationException If the base class throws it.
 */
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  Nameable previousContainer=getContainer();
  super.setContainer(container);
  if (container != previousContainer) {
    _remove();
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to remove the plot from its graphical container if the argument is null.
 * @param container The proposed container.
 * @exception IllegalActionException If the base class throws it.
 * @exception NameDuplicationException If the base class throws it.
 */
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException {
  Nameable previousContainer=getContainer();
  super.setContainer(container);
  if (container != previousContainer && previousContainer != null) {
    _remove();
  }
}