nus-yam/ex-repair huggingface dataset:
Program: 75157
Project: 75157
Buggy source:
/** 
 * React to a change of the _director or other property. 
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == directorClass) {
    final String newDirectorClassName=directorClass.stringValue();
    final Director director=getDirector();
    ChangeRequest request=new ChangeRequest(this,"String_Node_Str"){
      protected void _execute() throws Exception {
        Class newDirectorClass=Class.forName(newDirectorClassName);
        Constructor newDirectorConstructor=newDirectorClass.getConstructor(new Class[]{CompositeEntity.class,String.class});
        FSMDirector newDirector=(FSMDirector)newDirectorConstructor.newInstance(new Object[]{ModalModel.this,uniqueName("String_Node_Str")});
        newDirector.setPersistent(false);
        newDirector.controllerName.setExpression("String_Node_Str");
        if (director != null && director.getContainer() == ModalModel.this) {
          director.setContainer(null);
        }
      }
    }
;
    requestChange(request);
  }
}

Fixed version (ground truth):
/** 
 * React to a change of the director or other property. 
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == directorClass) {
    Director director=getDirector();
    String className=directorClass.stringValue();
    if (director == null || !director.getClass().getName().equals(className)) {
      try {
        Class.forName(className);
      }
 catch (      ClassNotFoundException e) {
        throw new IllegalActionException(this,null,e,"String_Node_Str");
      }
      ChangeRequest request=new ChangeRequest(this,"String_Node_Str"){
        protected void _execute() throws Exception {
          Director director=getDirector();
          Class newDirectorClass=Class.forName(directorClass.stringValue());
          Constructor newDirectorConstructor=newDirectorClass.getConstructor(new Class[]{CompositeEntity.class,String.class});
          FSMDirector newDirector=(FSMDirector)newDirectorConstructor.newInstance(new Object[]{ModalModel.this,uniqueName("String_Node_Str")});
          newDirector.setPersistent(false);
          newDirector.controllerName.setExpression("String_Node_Str");
          if (director != null && director.getContainer() == ModalModel.this) {
            director.setContainer(null);
          }
        }
      }
;
      requestChange(request);
    }
  }
}
Program: 75158
Project: 75158
Buggy source:
/** 
 * Override the base class to ensure that the _controller private variable is reset to the controller of the cloned object.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return The new Entity.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  ModalModel newModel=(ModalModel)super.clone(workspace);
  newModel._controller=(FSMActor)newModel.getEntity("String_Node_Str");
  return newModel;
}

Fixed version (ground truth):
/** 
 * Override the base class to ensure that the _controller private variable is reset to the controller of the cloned object.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If cloned ports cannot haveas their container the cloned entity (this should not occur), or if one of the attributes cannot be cloned.
 * @return The new Entity.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  ModalModel newModel=(ModalModel)super.clone(workspace);
  newModel._controller=(FSMActor)newModel.getEntity("String_Node_Str");
  try {
    newModel.directorClass.validate();
    newModel.executeChangeRequests();
  }
 catch (  IllegalActionException e) {
    throw new CloneNotSupportedException("String_Node_Str" + getFullName());
  }
  return newModel;
}
Program: 75159
Project: 75159
Buggy source:
protected void _execute() throws Exception {
  Class newDirectorClass=Class.forName(newDirectorClassName);
  Constructor newDirectorConstructor=newDirectorClass.getConstructor(new Class[]{CompositeEntity.class,String.class});
  FSMDirector newDirector=(FSMDirector)newDirectorConstructor.newInstance(new Object[]{ModalModel.this,uniqueName("String_Node_Str")});
  newDirector.setPersistent(false);
  newDirector.controllerName.setExpression("String_Node_Str");
  if (director != null && director.getContainer() == ModalModel.this) {
    director.setContainer(null);
  }
}

Fixed version (ground truth):
protected void _execute() throws Exception {
  Director director=getDirector();
  Class newDirectorClass=Class.forName(directorClass.stringValue());
  Constructor newDirectorConstructor=newDirectorClass.getConstructor(new Class[]{CompositeEntity.class,String.class});
  FSMDirector newDirector=(FSMDirector)newDirectorConstructor.newInstance(new Object[]{ModalModel.this,uniqueName("String_Node_Str")});
  newDirector.setPersistent(false);
  newDirector.controllerName.setExpression("String_Node_Str");
  if (director != null && director.getContainer() == ModalModel.this) {
    director.setContainer(null);
  }
}
Program: 75160
Project: 75160
Buggy source:
private void _init() throws IllegalActionException, NameDuplicationException {
  new Attribute(this,"String_Node_Str");
  setClassName("String_Node_Str");
  FSMDirector director=new FSMDirector(this,"String_Node_Str");
  _controller=new ModalController(this,"String_Node_Str");
  director.controllerName.setExpression("String_Node_Str");
  directorClass=new StringParameter(this,"String_Node_Str");
  Director executiveDirector=getExecutiveDirector();
  if (executiveDirector != null) {
    String[] suggestions=executiveDirector.suggestedModalModelDirectors();
    for (int i=0; i < suggestions.length; i++) {
      directorClass.addChoice(suggestions[i]);
      if (i == 0) {
        directorClass.setExpression(suggestions[i]);
      }
    }
  }
 else {
    directorClass.setExpression("String_Node_Str");
  }
  _attachText("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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}

Fixed version (ground truth):
private void _init() throws IllegalActionException, NameDuplicationException {
  new Attribute(this,"String_Node_Str");
  setClassName("String_Node_Str");
  _controller=new ModalController(this,"String_Node_Str");
  directorClass=new StringParameter(this,"String_Node_Str");
  Director executiveDirector=getExecutiveDirector();
  if (executiveDirector != null) {
    String[] suggestions=executiveDirector.suggestedModalModelDirectors();
    for (int i=0; i < suggestions.length; i++) {
      directorClass.addChoice(suggestions[i]);
      if (i == 0) {
        directorClass.setExpression(suggestions[i]);
      }
    }
  }
 else {
    directorClass.setExpression("String_Node_Str");
  }
  _attachText("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"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 75161
Project: 75161
Buggy source:
/** 
 * React to a change of the _director or other property. 
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == directorClass) {
    FSMDirector director=(FSMDirector)getDirector();
    Class newDirectorClass=null;
    String newDirectorClassName=directorClass.stringValue();
    try {
      if (director != null && director.getContainer() == this) {
        director.setContainer(null);
      }
      newDirectorClass=Class.forName(newDirectorClassName);
      Constructor newDirectorConstructor=newDirectorClass.getConstructor(new Class[]{CompositeEntity.class,String.class});
      director=(FSMDirector)newDirectorConstructor.newInstance(new Object[]{this,"String_Node_Str"});
    }
 catch (    NameDuplicationException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    ClassNotFoundException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    NoSuchMethodException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    InstantiationException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    IllegalAccessException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    InvocationTargetException ex) {
      throw new IllegalActionException(ex.toString());
    }
    director.controllerName.setExpression("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * React to a change of the _director or other property. 
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == directorClass) {
    Class newDirectorClass=null;
    String newDirectorClassName=directorClass.stringValue();
    try {
      Director director=getDirector();
      if (director != null && director.getContainer() == this) {
        director.setContainer(null);
      }
      newDirectorClass=Class.forName(newDirectorClassName);
      Constructor newDirectorConstructor=newDirectorClass.getConstructor(new Class[]{CompositeEntity.class,String.class});
      director=(FSMDirector)newDirectorConstructor.newInstance(new Object[]{this,"String_Node_Str"});
      ((FSMDirector)director).controllerName.setExpression("String_Node_Str");
    }
 catch (    NameDuplicationException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    ClassNotFoundException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    NoSuchMethodException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    InstantiationException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    IllegalAccessException ex) {
      throw new IllegalActionException(ex.toString());
    }
catch (    InvocationTargetException ex) {
      throw new IllegalActionException(ex.toString());
    }
  }
}
Program: 75166
Project: 75166
Buggy source:
public void generateInitializeCode(StringBuffer stream) throws IllegalActionException {
  stream.append(processCode(_initBlock));
}

Fixed version (ground truth):
public String generateInitializeCode() throws IllegalActionException {
  return processCode(_initBlock);
}
Program: 75172
Project: 75172
Buggy source:
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Exec(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  command=new PortParameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
  command.setStringMode(true);
  directory=new FileParameter(this,"String_Node_Str");
  directory.setExpression("String_Node_Str");
  directory.setVisibility(Settable.EXPERT);
  environment=new Parameter(this,"String_Node_Str");
  String[] labels=new String[]{"String_Node_Str","String_Node_Str"};
  Type[] values=new Type[]{BaseType.STRING,BaseType.STRING};
  environment.setTypeEquals(new ArrayType(new RecordType(labels,values)));
  environment.setExpression("String_Node_Str");
  environment.setVisibility(Settable.EXPERT);
  error=new TypedIOPort(this,"String_Node_Str",false,true);
  error.setTypeEquals(BaseType.STRING);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setTypeEquals(BaseType.STRING);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.STRING);
}

Fixed version (ground truth):
/** 
 * Construct an actor with the given container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public Exec(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  command=new PortParameter(this,"String_Node_Str",new StringToken("String_Node_Str"));
  command.setStringMode(true);
  new Parameter(command.getPort(),"String_Node_Str",BooleanToken.TRUE);
  directory=new FileParameter(this,"String_Node_Str");
  directory.setExpression("String_Node_Str");
  environment=new Parameter(this,"String_Node_Str");
  String[] labels=new String[]{"String_Node_Str","String_Node_Str"};
  Type[] values=new Type[]{BaseType.STRING,BaseType.STRING};
  environment.setTypeEquals(new ArrayType(new RecordType(labels,values)));
  environment.setExpression("String_Node_Str");
  error=new TypedIOPort(this,"String_Node_Str",false,true);
  error.setTypeEquals(BaseType.STRING);
  new Parameter(error,"String_Node_Str",BooleanToken.TRUE);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setTypeEquals(BaseType.STRING);
  new Parameter(input,"String_Node_Str",BooleanToken.TRUE);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setTypeEquals(BaseType.STRING);
  new Parameter(output,"String_Node_Str",BooleanToken.TRUE);
}
Program: 75173
Project: 75173
Buggy source:
/** 
 * Override the base class and terminate the process.
 */
public synchronized void stop(){
  super.stop();
  try {
    _terminateProcess();
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(ex);
  }
}

Fixed version (ground truth):
/** 
 * Override the base class and terminate the process.
 */
public void stop(){
  super.stop();
  try {
    _terminateProcess();
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(ex);
  }
}
Program: 75174
Project: 75174
Buggy source:
private void _read(){
  char[] chars=new char[80];
  int length;
  try {
    while ((length=_inputStreamReader.read(chars,0,80)) != -1 && !_stopRequested && !_stopFireRequested) {
      if (_debugging) {
        _debug("String_Node_Str" + getName() + "String_Node_Str"+ _inputStreamReader.ready()+ "String_Node_Str"+ String.valueOf(chars,0,length)+ "String_Node_Str");
      }
      _stringBuffer.append(chars,0,length);
    }
  }
 catch (  Throwable throwable) {
    throw new InternalErrorException(_actor,throwable,getName() + "String_Node_Str" + _inputStream);
  }
}

Fixed version (ground truth):
private synchronized void _read(){
  char[] chars=new char[80];
  int length;
  try {
    while ((length=_inputStreamReader.read(chars,0,80)) != -1 && !_stopRequested && !_stopFireRequested) {
      if (_debugging) {
        _debug("String_Node_Str" + getName() + "String_Node_Str"+ _inputStreamReader.ready()+ "String_Node_Str"+ String.valueOf(chars,0,length)+ "String_Node_Str");
      }
      _stringBuffer.append(chars,0,length);
    }
  }
 catch (  Throwable throwable) {
    throw new InternalErrorException(_actor,throwable,getName() + "String_Node_Str" + _inputStream);
  }
}
Program: 75175
Project: 75175
Buggy source:
/** 
 * Override the base class to stop waiting for input data.
 */
public synchronized void stopFire(){
  super.stopFire();
  _stopFireRequested=true;
  try {
    _terminateProcess();
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(ex);
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to stop waiting for input data.
 */
public void stopFire(){
  super.stopFire();
  _stopFireRequested=true;
  try {
    _terminateProcess();
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException(ex);
  }
}
Program: 75178
Project: 75178
Buggy source:
/** 
 * Read lines from the inputStream and append them to the stringBuffer.
 */
public void run(){
  _read();
}

Fixed version (ground truth):
/** 
 * Read lines from the inputStream and append them to the stringBuffer.
 */
public synchronized void run(){
  if (!_inputStreamReaderClosed) {
    _read();
  }
}
Program: 75179
Project: 75179
Buggy source:
/** 
 * Read any remaining data in the input stream and return the data read thus far.  Calling this method resets the cache of data read thus far.
 */
public String getAndReset(){
  if (_debugging) {
    try {
      _debug("String_Node_Str" + getName() + "String_Node_Str"+ _inputStreamReader.ready()+ "String_Node_Str"+ _inputStream.available());
    }
 catch (    Exception ex) {
      throw new InternalErrorException(ex);
    }
  }
  try {
    _read();
  }
 catch (  Throwable throwable) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + throwable.getMessage());
    }
  }
  String results=_stringBuffer.toString();
  _stringBuffer=new StringBuffer();
  try {
    _inputStreamReader.close();
  }
 catch (  Exception ex) {
    throw new InternalErrorException(null,ex,getName() + "String_Node_Str");
  }
  return results;
}

Fixed version (ground truth):
/** 
 * Read any remaining data in the input stream and return the data read thus far.  Calling this method resets the cache of data read thus far.
 */
public String getAndReset(){
  if (_debugging) {
    try {
      _debug("String_Node_Str" + getName() + "String_Node_Str"+ _inputStreamReader.ready()+ "String_Node_Str"+ _inputStream.available());
    }
 catch (    Exception ex) {
      throw new InternalErrorException(ex);
    }
  }
  try {
    _read();
  }
 catch (  Throwable throwable) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + throwable.getMessage());
    }
  }
  String results=_stringBuffer.toString();
  _stringBuffer=new StringBuffer();
  try {
    _inputStreamReader.close();
    _inputStreamReaderClosed=true;
  }
 catch (  Exception ex) {
    throw new InternalErrorException(null,ex,getName() + "String_Node_Str");
  }
  return results;
}
Program: 75183
Project: 75183
Buggy source:
/** 
 * Record whether the data associated with this effigy has been modified since it was first read or last saved.  If you call this with a true argument, then subsequent calls to isModified() will return true.  This is used by instances of TableauFrame. This is recorded in the entity returned by topEntity(), which is the one associated with a file.
 * @param modified True if the data has been modified.
 */
public void setModified(boolean modified){
  topEffigy()._modified=modified;
}

Fixed version (ground truth):
/** 
 * Record whether the data associated with this effigy has been modified since it was first read or last saved.  If you call this with a true argument, then subsequent calls to isModified() will return true.  This is used by instances of TableauFrame. This is recorded in the entity returned by topEntity(), which is the one associated with a file. This always sets a flag in the master effigy (as returned by masterEffigy()).
 * @see #masterEffigy()
 * @see #isModifiable()
 * @see #isModified()
 * @see #setModifiable()
 * @param modified True if the data has been modified.
 */
public void setModified(boolean modified){
  masterEffigy()._modified=modified;
}
Program: 75184
Project: 75184
Buggy source:
/** 
 * Return whether the model data is modifiable.  In this case, this is determined by checking whether the URI associated with this effigy can be written to.  This will return false if either there is no URI associated with this effigy, or the URI is not a file, or the file is not writable or does not exist, or setModifiable() has been called with a false argument.
 * @return False to indicate that the model is not modifiable.
 */
public boolean isModifiable(){
  if (!_modifiable)   return false;
 else   return _modifiableURI;
}

Fixed version (ground truth):
/** 
 * Return whether the model data is modifiable.  This is delegated to the effigy returned by masterEffigy().  If this is the master effigy, then whether the data is modifiable depends on whether setModifiable() has been called, and if not, on whether there is a URI associated with this effigy and whether that URI is writable.
 * @see #masterEffigy()
 * @return False to indicate that the model is not modifiable.
 */
public boolean isModifiable(){
  Effigy master=masterEffigy();
  if (!master._modifiable)   return false;
 else   return master._modifiableURI;
}
Program: 75185
Project: 75185
Buggy source:
/** 
 * Return the value set by setModified(), or false if setModified() has not been called on this effigy or any effigy contained by the same top effigy (returned by topEffigy()). This method is intended to be used to keep track of whether the data in the file or URI associated with this data has been modified.  The method is called by an instance of TableauFrame to determine whether it is safe to close.
 * @see #setModifiable(boolean)
 * @return True if the data has been modified.
 */
public boolean isModified(){
  return topEffigy()._modified;
}

Fixed version (ground truth):
/** 
 * Return the data associated with the master effigy (as returned by masterEffigy()) has been modified. This method is intended to be used to keep track of whether the data in the file or URI associated with this data has been modified.  The method is called by an instance of TableauFrame to determine whether it is safe to close.
 * @see #masterEffigy()
 * @see #setModifiable(boolean)
 * @return True if the data has been modified.
 */
public boolean isModified(){
  return masterEffigy()._modified;
}
Program: 75186
Project: 75186
Buggy source:
/** 
 * If the argument is false, the specify that that the model is not modifiable, even if the URI associated with this effigy is writable. If the argument is true, or if this method is never called, then whether the model is modifiable is determined by whether the URI can be written to. Notice that this does not automatically result in any tableaux that are contained switching to being uneditable.  But it will prevent them from writing to the URI.
 * @see #isModifiable()
 * @param flag False to prevent writing to the URI.
 */
public void setModifiable(boolean flag){
  _modifiable=flag;
}

Fixed version (ground truth):
/** 
 * If the argument is false, the specify that that the model is not modifiable, even if the URI associated with this effigy is writable. This always sets a flag in the master effigy (as returned by masterEffigy()). If the argument is true, or if this method is never called, then whether the model is modifiable is determined by whether the URI can be written to. Notice that this does not automatically result in any tableaux that are contained switching to being uneditable.  But it will prevent them from writing to the URI.
 * @see #masterEffigy()
 * @see #isModifiable()
 * @see #isModified()
 * @see #setModified(boolean)
 * @param flag False to prevent writing to the URI.
 */
public void setModifiable(boolean flag){
  masterEffigy()._modifiable=flag;
}
Program: 75188
Project: 75188
Buggy source:
/** 
 * Write the model to the specified file.  This method delegates to the top effigy containing the associated Tableau, if there is one, and otherwise throws an exception. This ensures that the data written is the description of the entire model, not just the portion within some composite actor.   It also adjusts the URIAttribute in the model to match the specified file, if necessary, and creates one otherwise.  It also overrides the base class to update the attributes if they need to update their content.
 * @param file The file to write to.
 * @exception IOException If the write fails.
 */
protected void _writeFile(File file) throws IOException {
  Tableau tableau=getTableau();
  if (tableau != null) {
    Effigy effigy=(Effigy)tableau.getContainer();
    if (effigy != null) {
      if (_model != null) {
        Iterator attributes=_model.attributeList(Attribute.class).iterator();
        while (attributes.hasNext()) {
          Attribute attribute=(Attribute)attributes.next();
          attribute.updateContent();
        }
      }
      if (_model == null) {
        effigy=effigy.topEffigy();
      }
 else       if (_query == null || (_model.getContainer() != null && !_query.getBooleanValue("String_Node_Str"))) {
        NamedObj toplevel=_model.toplevel();
        Effigy effigyForToplevel=Configuration.findEffigy(toplevel);
        if (effigyForToplevel != null) {
          effigy=effigyForToplevel;
        }
      }
      effigy.writeFile(file);
      return;
    }
  }
  throw new IOException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Write the model to the specified file.  This method delegates to the top effigy containing the associated Tableau, if there is one, and otherwise throws an exception. This ensures that the data written is the description of the entire model, not just the portion within some composite actor.   It also adjusts the URIAttribute in the model to match the specified file, if necessary, and creates one otherwise.  It also overrides the base class to update the attributes if they need to update their content.
 * @param file The file to write to.
 * @exception IOException If the write fails.
 */
protected void _writeFile(File file) throws IOException {
  Tableau tableau=getTableau();
  if (tableau != null) {
    Effigy effigy=(Effigy)tableau.getContainer();
    if (effigy != null) {
      if (_model != null) {
        Iterator attributes=_model.attributeList(Attribute.class).iterator();
        while (attributes.hasNext()) {
          Attribute attribute=(Attribute)attributes.next();
          attribute.updateContent();
        }
      }
      if (_model == null) {
        effigy=effigy.topEffigy();
      }
 else       if (_query == null || (_model.getContainer() != null && !_query.getBooleanValue("String_Node_Str"))) {
        effigy=effigy.masterEffigy();
      }
      effigy.writeFile(file);
      return;
    }
  }
  throw new IOException("String_Node_Str");
}
Program: 75189
Project: 75189
Buggy source:
/** 
 * Create a tableau to run the model associated with the specified effigy.  The top-level effigy, as returned by  {@link Effigy#topEffigy()}, is the one that is run. If that effigy already contains a tableau named "runTableau", then return that tableau; otherwise, create a new instance of RunTableau for the top effigy, and name it "runTableau".  If the specified effigy is not an instance of PtolemyEffigy, then do not create a tableau and return null. It is the responsibility of callers of this method to check the return value and call show().
 * @param effigy The model effigy.
 * @return A new run tableau if the effigy is a PtolemyEffigy,or null otherwise.
 * @exception Exception If the factory should be able to create atableau for the effigy, but something goes wrong.
 */
public Tableau createTableau(Effigy effigy) throws Exception {
  return super.createTableau(effigy.topEffigy());
}

Fixed version (ground truth):
/** 
 * Create a tableau to run the model associated with the specified effigy.  The top-level effigy, as returned by  {@link Effigy#masterEffigy()}, is the one that is run. If that effigy already contains a tableau named "runTableau", then return that tableau; otherwise, create a new instance of RunTableau for the top effigy, and name it "runTableau".  If the specified effigy is not an instance of PtolemyEffigy, then do not create a tableau and return null. It is the responsibility of callers of this method to check the return value and call show().
 * @param effigy The model effigy.
 * @return A new run tableau if the effigy is a PtolemyEffigy,or null otherwise.
 * @exception Exception If the factory should be able to create atableau for the effigy, but something goes wrong.
 */
public Tableau createTableau(Effigy effigy) throws Exception {
  return super.createTableau(effigy.masterEffigy());
}
Program: 75190
Project: 75190
Buggy source:
/** 
 * Return true if this tableau is a master, which means that if that if its window is closed, then all other windows associated with the model are also closed.
 * @return True if the tableau is a master.
 */
public boolean isMaster(){
  return _master;
}

Fixed version (ground truth):
/** 
 * Return true if this tableau is a master, which means that if that if its window is closed, then all other windows associated with the model are also closed. A tableau is a master if its container effigy is a master (its masterEffigy() method returns itself).
 * @return True if the tableau is a master.
 */
public boolean isMaster(){
  return _master;
}
Program: 75191
Project: 75191
Buggy source:
/** 
 * Close the window.  Derived classes should override this to release any resources or remove any listeners.  In this class, if the data associated with this window has been modified, and there are no other tableaux in the parent effigy or any effigy that contains it, then ask the user whether to save the data before closing.
 * @return False if the user cancels on a save query.
 */
protected boolean _close(){
  if (getEffigy() == null) {
    return super._close();
  }
  Effigy topEffigy=getEffigy().topEffigy();
  if (!_tableau.isMaster()) {
    List tableaux=topEffigy.entityList(Tableau.class);
    Iterator tableauxIterator=tableaux.iterator();
    while (tableauxIterator.hasNext()) {
      Tableau tableau=(Tableau)tableauxIterator.next();
      if (!(tableau instanceof DialogTableau) && (tableau != _tableau)) {
        dispose();
        return true;
      }
    }
  }
  if (isModified()) {
    int reply=_queryForSave();
    if (reply == _DISCARDED || reply == _FAILED) {
      if (!_checkForDerivedObjects()) {
        return false;
      }
    }
    if (reply == _SAVED || reply == _DISCARDED) {
      dispose();
      return true;
    }
    return false;
  }
 else {
    dispose();
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Close the window.  Derived classes should override this to release any resources or remove any listeners.  In this class, if the data associated with this window have been modified, and there are no other tableaux in the parent effigy or any effigy that contains it, then ask the user whether to save the data before closing.
 * @return False if the user cancels on a save query.
 */
protected boolean _close(){
  if (getEffigy() == null) {
    return super._close();
  }
  Effigy masterEffigy=getEffigy().masterEffigy();
  if (!_tableau.isMaster()) {
    List tableaux=masterEffigy.entityList(Tableau.class);
    Iterator tableauxIterator=tableaux.iterator();
    while (tableauxIterator.hasNext()) {
      Tableau tableau=(Tableau)tableauxIterator.next();
      if (!(tableau instanceof DialogTableau) && (tableau != _tableau)) {
        dispose();
        return true;
      }
    }
  }
  if (isModified()) {
    int reply=_queryForSave();
    if (reply == _DISCARDED || reply == _FAILED) {
      if (!_checkForDerivedObjects()) {
        return false;
      }
    }
    if (reply == _SAVED) {
      dispose();
      return true;
    }
 else     if (reply == _DISCARDED) {
      dispose();
      setModified(false);
      try {
        MoMLParser.purgeModelRecord(masterEffigy.uri.getURL());
      }
 catch (      MalformedURLException e) {
      }
      return true;
    }
    return false;
  }
 else {
    dispose();
    return true;
  }
}
Program: 75192
Project: 75192
Buggy source:
/** 
 * Report an exception if it occurred in a background run.
 * @exception IllegalActionException If there is no director, or ifa background run threw an exception.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  if (_throwable != null) {
    Throwable throwable=_throwable;
    _throwable=null;
    throw new IllegalActionException(this,throwable,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Report an exception if it occurred in a background run.
 * @exception IllegalActionException If there is no director, or ifa background run threw an exception.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  _alreadyReadInputs=false;
  if (_throwable != null) {
    Throwable throwable=_throwable;
    _throwable=null;
    throw new IllegalActionException(this,throwable,"String_Node_Str");
  }
}
Program: 75194
Project: 75194
Buggy source:
/** 
 * Iterate over input ports and read any available values into the referenced model parameters.
 * @exception IllegalActionException If reading the ports orsetting the parameters causes it.
 */
private void _readInputs() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  Iterator ports=inputPortList().iterator();
  while (ports.hasNext()) {
    IOPort port=(IOPort)ports.next();
    if (port instanceof ParameterPort) {
      PortParameter parameter=((ParameterPort)port).getParameter();
      if (_debugging) {
        _debug("String_Node_Str" + port.getName());
      }
      parameter.update();
      continue;
    }
    if (port.getWidth() > 0 && port.hasToken(0)) {
      Token token=port.get(0);
      Attribute attribute=_model.getAttribute(port.getName());
      if (attribute instanceof Variable) {
        if (_debugging) {
          _debug("String_Node_Str" + port.getName());
        }
        ((Variable)attribute).setToken(token);
      }
 else       if (attribute instanceof Settable) {
        if (_debugging) {
          _debug("String_Node_Str" + port.getName());
        }
        ((Settable)attribute).setExpression(token.toString());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Iterate over input ports and read any available values into the referenced model parameters.
 * @exception IllegalActionException If reading the ports orsetting the parameters causes it.
 */
protected void _readInputs() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  Iterator ports=inputPortList().iterator();
  while (ports.hasNext()) {
    IOPort port=(IOPort)ports.next();
    if (port instanceof ParameterPort) {
      PortParameter parameter=((ParameterPort)port).getParameter();
      if (_debugging) {
        _debug("String_Node_Str" + port.getName());
      }
      parameter.update();
      continue;
    }
    if (port.getWidth() > 0 && port.hasToken(0)) {
      Token token=port.get(0);
      Attribute attribute=_model.getAttribute(port.getName());
      if (attribute instanceof Variable) {
        if (_debugging) {
          _debug("String_Node_Str" + port.getName());
        }
        ((Variable)attribute).setToken(token);
      }
 else       if (attribute instanceof Settable) {
        if (_debugging) {
          _debug("String_Node_Str" + port.getName());
        }
        ((Settable)attribute).setExpression(token.toString());
      }
    }
  }
}
Program: 75197
Project: 75197
Buggy source:
/** 
 * Override the base class to perform requested close on postfire actions. Note that if a close is requested, then this method waits until the AWT event thread completes the close.  This creates the possibility of a deadlock.
 * @return Whatever the superclass returns (probably true).
 * @exception IllegalActionException Thrown if a parent class throws it.
 */
public boolean postfire() throws IllegalActionException {
  boolean result=super.postfire();
  if (_tableau != null) {
    final JFrame frame=_tableau.getFrame();
    if (_closeOnPostfireValue == _CLOSE_VERGIL_GRAPH) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      if (frame instanceof ExtendedGraphFrame) {
        ((ExtendedGraphFrame)frame).cancelFullScreen();
      }
      if (frame instanceof TableauFrame) {
        Runnable doClose=new Runnable(){
          public void run(){
            ((TableauFrame)frame).close();
          }
        }
;
        try {
          SwingUtilities.invokeAndWait(doClose);
        }
 catch (        Exception ex) {
        }
      }
 else       if (frame != null) {
        Runnable doClose=new Runnable(){
          public void run(){
            frame.hide();
          }
        }
;
        Top.deferIfNecessary(doClose);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Override the base class to perform requested close on postfire actions. Note that if a close is requested, then this method waits until the AWT event thread completes the close.  This creates the possibility of a deadlock.
 * @return Whatever the superclass returns (probably true).
 * @exception IllegalActionException Thrown if a parent class throws it.
 */
public boolean postfire() throws IllegalActionException {
  boolean result=super.postfire();
  if (_tableau != null) {
    final JFrame frame=_tableau.getFrame();
    if (_closeOnPostfireValue == _CLOSE_VERGIL_GRAPH) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      if (frame instanceof TableauFrame) {
        Runnable doClose=new Runnable(){
          public void run(){
            if (frame instanceof ExtendedGraphFrame) {
              ((ExtendedGraphFrame)frame).cancelFullScreen();
            }
            ((TableauFrame)frame).close();
          }
        }
;
        Top.deferIfNecessary(doClose);
      }
 else       if (frame != null) {
        Runnable doClose=new Runnable(){
          public void run(){
            if (frame instanceof ExtendedGraphFrame) {
              ((ExtendedGraphFrame)frame).cancelFullScreen();
            }
            frame.hide();
          }
        }
;
        Top.deferIfNecessary(doClose);
      }
    }
  }
  return result;
}
Program: 75199
Project: 75199
Buggy source:
public void run(){
  frame.hide();
}

Fixed version (ground truth):
public void run(){
  if (frame instanceof ExtendedGraphFrame) {
    ((ExtendedGraphFrame)frame).cancelFullScreen();
  }
  frame.hide();
}
Program: 75202
Project: 75202
Buggy source:
/** 
 * Construct an actor with the specified container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public ContinuousClock(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  defaultValue=new Parameter(this,"String_Node_Str");
  defaultValue.setExpression("String_Node_Str");
  ((Parameter)output.getAttribute("String_Node_Str")).setToken(new StringToken("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Construct an actor with the specified container and name.
 * @param container The container.
 * @param name The name of this actor.
 * @exception IllegalActionException If the entity cannot be containedby the proposed container.
 * @exception NameDuplicationException If the container already has anactor with this name.
 */
public ContinuousClock(CompositeEntity container,String name) throws NameDuplicationException, IllegalActionException {
  super(container,name);
  defaultValue=new Parameter(this,"String_Node_Str");
  defaultValue.setExpression("String_Node_Str");
  ((Parameter)output.getAttribute("String_Node_Str")).setToken(new StringToken("String_Node_Str"));
  ((Parameter)trigger.getAttribute("String_Node_Str")).setToken(new StringToken("String_Node_Str"));
}
Program: 75203
Project: 75203
Buggy source:
/** 
 * Initialize the execution.
 * @exception IllegalActionException If thrown by the super class.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _eventMissed=false;
  _eventNow=false;
  _lastTrigger=((DoubleToken)initialState.getToken()).doubleValue();
  _thisTrigger=0.0;
  _level=0.0;
}

Fixed version (ground truth):
/** 
 * Initialize the execution.
 * @exception IllegalActionException If thrown by the super class.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _eventMissed=false;
  _eventNow=false;
  _lastTrigger=((DoubleToken)initialState.getToken()).doubleValue();
  _thisTrigger=0.0;
  _level=((DoubleToken)level.getToken()).doubleValue();
  ;
}
Program: 75204
Project: 75204
Buggy source:
/** 
 * Assuming the contents of the clipboard is MoML code, paste it into the current model by issuing a change request.
 */
public void paste(){
  Clipboard clipboard=java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
  Transferable transferable=clipboard.getContents(this);
  GraphModel model=_getGraphModel();
  if (transferable == null)   return;
  try {
    NamedObj container=(NamedObj)model.getRoot();
    StringBuffer moml=new StringBuffer();
    moml.append("String_Node_Str");
    moml.append((String)transferable.getTransferData(DataFlavor.stringFlavor));
    moml.append("String_Node_Str");
    MoMLChangeRequest change=new MoMLChangeRequest(this,container,moml.toString());
    change.setUndoable(true);
    container.requestChange(change);
  }
 catch (  Exception ex) {
    MessageHandler.error("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
/** 
 * Assuming the contents of the clipboard is MoML code, paste it into the current model by issuing a change request.
 */
public void paste(){
  Clipboard clipboard=java.awt.Toolkit.getDefaultToolkit().getSystemClipboard();
  Transferable transferable=clipboard.getContents(this);
  GraphModel model=_getGraphModel();
  if (transferable == null)   return;
  try {
    NamedObj container=(NamedObj)model.getRoot();
    StringBuffer moml=new StringBuffer();
    moml.append("String_Node_Str");
    moml.append(offsetPastedMomlLocation((String)transferable.getTransferData(DataFlavor.stringFlavor),10,10));
    moml.append("String_Node_Str");
    MoMLChangeRequest change=new MoMLChangeRequest(this,container,moml.toString());
    change.setUndoable(true);
    container.requestChange(change);
  }
 catch (  Exception ex) {
    MessageHandler.error("String_Node_Str",ex);
  }
}
Program: 75205
Project: 75205
Buggy source:
/** 
 * Consume the inputs and produce the output ArrayToken.
 * @exception IllegalActionException If not enough tokens are available.
 */
public void fire() throws IllegalActionException {
  super.fire();
  arrayLength.update();
  int length=((IntToken)arrayLength.getToken()).intValue();
  Token[] valueArray=input.get(0,length);
  output.send(0,new ArrayToken(valueArray));
}

Fixed version (ground truth):
/** 
 * Consume the inputs and produce the output ArrayToken.
 * @exception IllegalActionException If not enough tokens are available.
 */
public void fire() throws IllegalActionException {
  super.fire();
  arrayLength.update();
  int length=((IntToken)arrayLength.getToken()).intValue();
  Token[] valueArray=new Token[length];
  System.arraycopy(input.get(0,length),0,valueArray,0,length);
  output.send(0,new ArrayToken(valueArray));
}
Program: 75206
Project: 75206
Buggy source:
/** 
 * Create a new port with the specified name in the container of this controller, which in turn creates a port in this controller and all the refinements. This method is write-synchronized on the workspace.
 * @param name The name to assign to the newly created port.
 * @return The new port.
 * @exception NameDuplicationException If the entity already has a portwith the specified name.
 */
public Port newPort(String name) throws NameDuplicationException {
  try {
    _workspace.getWriteAccess();
    if (_mirrorDisable || getContainer() == null) {
      RefinementPort port=new RefinementPort(this,name);
      port._mirrorDisable=false;
      ModalModel container=(ModalModel)getContainer();
      if (container != null) {
        String relationName=name + "String_Node_Str";
        Relation relation=container.getRelation(relationName);
        if (relation == null) {
          relation=container.newRelation(relationName);
          Port containerPort=container.getPort(name);
          containerPort.link(relation);
        }
        port.link(relation);
      }
      return port;
    }
 else {
      _mirrorDisable=true;
      ((ModalModel)getContainer()).newPort(name);
      return getPort(name);
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
 finally {
    _mirrorDisable=false;
    _workspace.doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Create a new port with the specified name in the container of this controller, which in turn creates a port in this controller and all the refinements. This method is write-synchronized on the workspace.
 * @param name The name to assign to the newly created port.
 * @return The new port.
 * @exception NameDuplicationException If the entity already has a portwith the specified name.
 */
public Port newPort(String name) throws NameDuplicationException {
  try {
    _workspace.getWriteAccess();
    if (_mirrorDisable || getContainer() == null) {
      RefinementPort port=new RefinementPort(this,name);
      ModalModel container=(ModalModel)getContainer();
      if (container != null) {
        String relationName=name + "String_Node_Str";
        Relation relation=container.getRelation(relationName);
        if (relation == null) {
          relation=container.newRelation(relationName);
          Port containerPort=container.getPort(name);
          containerPort.link(relation);
        }
        port.link(relation);
      }
      return port;
    }
 else {
      _mirrorDisable=true;
      ((ModalModel)getContainer()).newPort(name);
      return getPort(name);
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
 finally {
    _mirrorDisable=false;
    _workspace.doneWriting();
  }
}
Program: 75208
Project: 75208
Buggy source:
/** 
 * Create a new port with the specified name in the container of this refinement, which in turn creates a port in this refinement all other refinements, and the controller. This method is write-synchronized on the workspace.
 * @param name The name to assign to the newly created port.
 * @return The new port.
 * @exception NameDuplicationException If the entity already has a portwith the specified name.
 */
public Port newPort(String name) throws NameDuplicationException {
  try {
    _workspace.getWriteAccess();
    if (_mirrorDisable || getContainer() == null) {
      RefinementPort port=new RefinementPort(this,name);
      port._mirrorDisable=false;
      ModalModel container=(ModalModel)getContainer();
      if (container != null) {
        String relationName=name + "String_Node_Str";
        Relation relation=container.getRelation(relationName);
        if (relation == null) {
          relation=container.newRelation(relationName);
          Port containerPort=container.getPort(name);
          containerPort.link(relation);
        }
        port.link(relation);
      }
      return port;
    }
 else {
      _mirrorDisable=true;
      ((ModalModel)getContainer()).newPort(name);
      return getPort(name);
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
 finally {
    _mirrorDisable=false;
    _workspace.doneWriting();
  }
}

Fixed version (ground truth):
/** 
 * Create a new port with the specified name in the container of this refinement, which in turn creates a port in this refinement all other refinements, and the controller. This method is write-synchronized on the workspace.
 * @param name The name to assign to the newly created port.
 * @return The new port.
 * @exception NameDuplicationException If the entity already has a portwith the specified name.
 */
public Port newPort(String name) throws NameDuplicationException {
  try {
    _workspace.getWriteAccess();
    if (_mirrorDisable || getContainer() == null) {
      RefinementPort port=new RefinementPort(this,name);
      ModalModel container=(ModalModel)getContainer();
      if (container != null) {
        String relationName=name + "String_Node_Str";
        Relation relation=container.getRelation(relationName);
        if (relation == null) {
          relation=container.newRelation(relationName);
          Port containerPort=container.getPort(name);
          containerPort.link(relation);
        }
        port.link(relation);
      }
      return port;
    }
 else {
      _mirrorDisable=true;
      ((ModalModel)getContainer()).newPort(name);
      return getPort(name);
    }
  }
 catch (  IllegalActionException ex) {
    throw new InternalErrorException("String_Node_Str" + ex.getMessage());
  }
 finally {
    _mirrorDisable=false;
    _workspace.doneWriting();
  }
}