nus-yam/ex-repair huggingface dataset:
Program: 74218
Project: 74218
Buggy source:
public void executeTransformation(CompositeEntity model) throws Exception {
  Manager manager=getModelUpdater().getManager();
  manager.addExecutionListener(new TransformationListener(manager,"String_Node_Str",model));
  for (  ExecutionListener listener : _executionListeners) {
    manager.addExecutionListener(listener);
  }
  Effigy masterEffigy=Configuration.findEffigy(toplevel());
  if (masterEffigy != null) {
    PtolemyEffigy effigy=new PtolemyEffigy(masterEffigy,masterEffigy.uniqueName("String_Node_Str"));
    effigy.setModel(_modelUpdater);
  }
  NamedObj container=getContainer();
  List<ParserAttribute> parsers=container.attributeList(ParserAttribute.class);
  ParserAttribute parserAttribute=parsers.size() > 0 ? parsers.get(0) : new ParserAttribute(container,container.uniqueName("String_Node_Str"));
  MoMLParser oldParser=parsers.size() > 0 ? parserAttribute.getParser() : null;
  parserAttribute.setParser(new MoMLParser());
  manager.enablePrintTimeAndMemory(false);
  try {
    manager.execute();
  }
  finally {
    manager.enablePrintTimeAndMemory(true);
    if (oldParser == null) {
      parserAttribute.setContainer(null);
    }
 else {
      parserAttribute.setParser(oldParser);
    }
  }
}

Fixed version (ground truth):
public void executeTransformation(CompositeEntity model) throws Exception {
  Manager manager=getModelUpdater().getManager();
  manager.addExecutionListener(new TransformationListener(manager,"String_Node_Str",model));
  for (  ExecutionListener listener : _executionListeners) {
    manager.addExecutionListener(listener);
  }
  NamedObj container=getContainer();
  List<ParserAttribute> parsers=container.attributeList(ParserAttribute.class);
  ParserAttribute parserAttribute=parsers.size() > 0 ? parsers.get(0) : new ParserAttribute(container,container.uniqueName("String_Node_Str"));
  MoMLParser oldParser=parsers.size() > 0 ? parserAttribute.getParser() : null;
  parserAttribute.setParser(new MoMLParser());
  manager.enablePrintTimeAndMemory(false);
  try {
    manager.execute();
  }
  finally {
    manager.enablePrintTimeAndMemory(true);
    if (oldParser == null) {
      parserAttribute.setContainer(null);
    }
 else {
      parserAttribute.setParser(oldParser);
    }
  }
}
Program: 74221
Project: 74221
Buggy source:
public UpdateContentsRequest(Object source,CompositeEntity modalModel,String entityName,String moml){
  super(source,"String_Node_Str" + entityName + "String_Node_Str");
  _modalModel=modalModel;
  _entityName=entityName;
  _moml=moml;
}

Fixed version (ground truth):
/** 
 * Construct a request.
 * @param source The state that originates the request.
 * @param modalModel The closest modal model that the source state iscontained in.
 * @param name The name of the refinement.
 * @param moml The moml of the refinement.
 */
public UpdateContentsRequest(State source,CompositeEntity modalModel,String name,String moml){
  super(source,"String_Node_Str" + name + "String_Node_Str");
  _modalModel=modalModel;
  _name=name;
  _moml=moml;
}
Program: 74223
Project: 74223
Buggy source:
protected void _execute() throws Exception {
  ComponentEntity entity=_modalModel.getEntity(_entityName);
  MoMLChangeRequest request=new MoMLChangeRequest(this,entity,_moml);
  request.execute();
}

Fixed version (ground truth):
/** 
 * Execute the change.
 * @exception Exception If the change fails.
 */
protected void _execute() throws Exception {
  ComponentEntity entity=_modalModel.getEntity(_name);
  MoMLChangeRequest request=new MoMLChangeRequest(this,entity,_moml);
  request.execute();
}
Program: 74224
Project: 74224
Buggy source:
private boolean _isAttributeCopied(Attribute attribute){
  if (!attribute.isPersistent() || attribute instanceof GTAttribute) {
    return false;
  }
  if (attribute instanceof Director || attribute instanceof Variable || attribute instanceof VisibleAttribute) {
    return true;
  }
  try {
    attribute.workspace().getReadAccess();
    if (!attribute.attributeList(Location.class).isEmpty()) {
      return true;
    }
  }
  finally {
    attribute.workspace().doneReading();
  }
  return false;
}

Fixed version (ground truth):
private boolean _isAttributeCopied(Attribute attribute){
  if (!attribute.isPersistent() || attribute instanceof GTAttribute || attribute instanceof GTEntity) {
    return false;
  }
  if (attribute instanceof Director || attribute instanceof Variable || attribute instanceof VisibleAttribute) {
    return true;
  }
  try {
    attribute.workspace().getReadAccess();
    if (!attribute.attributeList(Location.class).isEmpty()) {
      return true;
    }
  }
  finally {
    attribute.workspace().doneReading();
  }
  return false;
}
Program: 74225
Project: 74225
Buggy source:
/** 
 * Request a firing of the container of this director at the specified time and throw an exception if the executive director does not agree to do it at the requested time. If there is no executive director (this director is at the top level), then ignore the request. This is a convenience method provided because several directors need it.
 * @param time The requested time.
 * @return The time that the executive director indicates it will fire thisdirector, or an instance of Time with value Double.NEGATIVE_INFINITY if there is no executive director.
 * @exception IllegalActionException If the director does notagree to fire the actor at the specified time, or if there is no director.
 */
protected Time _fireAt(Time time) throws IllegalActionException {
  CompositeActor container=(CompositeActor)getContainer();
  if (container != null) {
    Director director=container.getExecutiveDirector();
    if (director != null) {
      Time result=director.fireAt(container,time);
      if (!result.equals(time)) {
        throw new IllegalActionException(this,"String_Node_Str" + time + "String_Node_Str"+ result);
      }
      return result;
    }
  }
  return new Time(this,Double.NEGATIVE_INFINITY);
}

Fixed version (ground truth):
/** 
 * Request a firing of the container of this director at the specified time and throw an exception if the executive director does not agree to do it at the requested time. If there is no executive director (this director is at the top level), then ignore the request. This is a convenience method provided because several directors need it.
 * @param time The requested time.
 * @return The time that the executive director indicates it will fire thisdirector, or an instance of Time with value Double.NEGATIVE_INFINITY if there is no executive director.
 * @exception IllegalActionException If the director does notagree to fire the actor at the specified time, or if there is no director.
 */
protected Time _fireAt(Time time) throws IllegalActionException {
  Actor container=(Actor)getContainer();
  if (container != null) {
    Director director=container.getExecutiveDirector();
    if (director != null) {
      Time result=director.fireAt(container,time);
      if (!result.equals(time)) {
        throw new IllegalActionException(this,"String_Node_Str" + time + "String_Node_Str"+ result);
      }
      return result;
    }
  }
  return new Time(this,Double.NEGATIVE_INFINITY);
}
Program: 74227
Project: 74227
Buggy source:
/** 
 * Create and return a file dialog for the "Save As" command. This overrides the base class to add options to the dialog.
 * @return A file dialog for save as.
 */
protected JFileChooser _saveAsFileDialog(){
  JFileChooser fileDialog=super._saveAsFileDialog();
  if (_exportDesignPattern) {
    if (!_getSelectionSet().isEmpty()) {
      _query=new Query();
      _query.addCheckBox("String_Node_Str","String_Node_Str",true);
      fileDialog.setAccessory(_query);
    }
  }
  return fileDialog;
}

Fixed version (ground truth):
/** 
 * Create and return a file dialog for the "Save As" command. This overrides the base class to add options to the dialog.
 * @return A file dialog for save as.
 */
protected JFileChooser _saveAsFileDialog(){
  JFileChooser fileDialog=super._saveAsFileDialog();
  if (_isDesignPattern()) {
    if (_getSelectionSet().isEmpty()) {
      fileDialog.setAccessory(null);
    }
 else {
      _query=new Query();
      _query.addCheckBox("String_Node_Str","String_Node_Str",true);
      fileDialog.setAccessory(_query);
    }
  }
  return fileDialog;
}
Program: 74228
Project: 74228
Buggy source:
/** 
 * Export the current submodel as a design pattern using a method similar to Save As.
 */
public void exportDesignPattern(){
  StringAttribute alternateGetMoml=null;
  DesignPatternIcon icon=null;
  try {
    NamedObj model=getModel();
    try {
      _exportDesignPattern=true;
      if (model.getAttribute("String_Node_Str") == null) {
        alternateGetMoml=new StringAttribute(model,"String_Node_Str");
        alternateGetMoml.setExpression(DesignPatternGetMoMLAction.class.getName());
      }
      if (model.getAttribute("String_Node_Str") == null) {
        icon=new DesignPatternIcon(model,"String_Node_Str");
      }
    }
 catch (    Exception e) {
      throw new InternalErrorException(null,e,"String_Node_Str" + "String_Node_Str");
    }
    _prepareExportDesignPattern();
    _saveAs();
  }
  finally {
    _finishExportDesignPattern();
    _exportDesignPattern=false;
    if (alternateGetMoml != null) {
      try {
        alternateGetMoml.setContainer(null);
      }
 catch (      KernelException e) {
      }
    }
    if (icon != null) {
      try {
        icon.setContainer(null);
      }
 catch (      KernelException e) {
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Export the current submodel as a design pattern using a method similar to Save As.
 */
public void exportDesignPattern(){
  StringAttribute alternateGetMoml=null;
  DesignPatternIcon icon=null;
  try {
    NamedObj model=getModel();
    try {
      if (model.getAttribute("String_Node_Str") == null) {
        alternateGetMoml=new StringAttribute(model,"String_Node_Str");
        alternateGetMoml.setExpression(DesignPatternGetMoMLAction.class.getName());
      }
      if (model.getAttribute("String_Node_Str") == null) {
        icon=new DesignPatternIcon(model,"String_Node_Str");
      }
    }
 catch (    Exception e) {
      throw new InternalErrorException(null,e,"String_Node_Str" + "String_Node_Str");
    }
    _prepareExportDesignPattern();
    _saveAs();
  }
  finally {
    _finishExportDesignPattern();
    if (alternateGetMoml != null) {
      try {
        alternateGetMoml.setContainer(null);
      }
 catch (      KernelException e) {
      }
    }
    if (icon != null) {
      try {
        icon.setContainer(null);
      }
 catch (      KernelException e) {
      }
    }
  }
}
Program: 74232
Project: 74232
Buggy source:
public void managerStateChanged(Manager manager){
  if (manager.getState() == Manager.INITIALIZING) {
    ModelParameter modelAttribute=(ModelParameter)transformer.getController().getAttribute("String_Node_Str");
    modelAttribute.setModel(context);
  }
}

Fixed version (ground truth):
public void managerStateChanged(Manager manager){
  if (manager.getState() == Manager.INITIALIZING) {
    ERGModalModel transformer=(ERGModalModel)manager.getContainer();
    ModelParameter modelAttribute=(ModelParameter)transformer.getController().getAttribute("String_Node_Str");
    modelAttribute.setModel((CompositeEntity)TransformationAttribute.this.getContainer());
  }
}
Program: 74234
Project: 74234
Buggy source:
/** 
 * Get a parser for the specified object. This searches up the hierarchy until it finds a container of the specified object that contains an instance of ParserAttribute. If none is found, then a new ParserAttribute is created at the top level.
 * @param object The object for which to find an associated parser.
 * @return The parser for the specified object.
 * @exception NullPointerException If the argument is null.
 * @see #setParser(MoMLParser)
 */
public static MoMLParser getParser(NamedObj object){
  NamedObj container=object;
  while (container != null) {
    List attributes=object.attributeList(ParserAttribute.class);
    if ((attributes != null) && (attributes.size() > 0)) {
      ParserAttribute attribute=(ParserAttribute)attributes.get(0);
      return attribute.getParser();
    }
    container=container.getContainer();
  }
  NamedObj toplevel=object.toplevel();
  try {
    ParserAttribute attribute=new ParserAttribute(toplevel,"String_Node_Str");
    return attribute.getParser();
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(ex);
  }
}

Fixed version (ground truth):
/** 
 * Get a parser for the specified object. This searches up the hierarchy until it finds a container of the specified object that contains an instance of ParserAttribute. If none is found, then a new ParserAttribute is created at the top level.
 * @param object The object for which to find an associated parser.
 * @return The parser for the specified object.
 * @exception NullPointerException If the argument is null.
 * @see #setParser(MoMLParser)
 */
public static MoMLParser getParser(NamedObj object){
  NamedObj container=object;
  while (container != null) {
    List attributes=container.attributeList(ParserAttribute.class);
    if ((attributes != null) && (attributes.size() > 0)) {
      ParserAttribute attribute=(ParserAttribute)attributes.get(0);
      return attribute.getParser();
    }
    container=container.getContainer();
  }
  NamedObj toplevel=object.toplevel();
  try {
    ParserAttribute attribute=new ParserAttribute(toplevel,"String_Node_Str");
    return attribute.getParser();
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(ex);
  }
}
Program: 74237
Project: 74237
Buggy source:
/** 
 * Get a parser for the specified object. This searches up the hierarchy until it finds a container of the specified object that contains an instance of ParserAttribute. If none is found, then a new ParserAttribute is created at the top level.
 * @param object The object for which to find an associated parser.
 * @return The parser for the specified object.
 * @exception NullPointerException If the argument is null.
 * @see #setParser(MoMLParser)
 */
public static MoMLParser getParser(NamedObj object){
  NamedObj container=object;
  while (container != null) {
    List attributes=container.attributeList(ParserAttribute.class);
    if ((attributes != null) && (attributes.size() > 0)) {
      ParserAttribute attribute=(ParserAttribute)attributes.get(0);
      return attribute.getParser();
    }
    container=container.getContainer();
  }
  NamedObj toplevel=object.toplevel();
  try {
    ParserAttribute attribute=new ParserAttribute(toplevel,"String_Node_Str");
    return attribute.getParser();
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(ex);
  }
}

Fixed version (ground truth):
/** 
 * Get a parser for the specified object. This searches up the hierarchy until it finds a container of the specified object that contains an instance of ParserAttribute. If none is found, then a new ParserAttribute is created at the top level.
 * @param object The object for which to find an associated parser.
 * @return The parser for the specified object.
 * @exception NullPointerException If the argument is null.
 * @see #setParser(MoMLParser)
 */
public static MoMLParser getParser(NamedObj object){
  NamedObj container=object;
  while (container != null) {
    List attributes=object.attributeList(ParserAttribute.class);
    if ((attributes != null) && (attributes.size() > 0)) {
      ParserAttribute attribute=(ParserAttribute)attributes.get(0);
      return attribute.getParser();
    }
    container=container.getContainer();
  }
  NamedObj toplevel=object.toplevel();
  try {
    ParserAttribute attribute=new ParserAttribute(toplevel,"String_Node_Str");
    return attribute.getParser();
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(ex);
  }
}
Program: 74239
Project: 74239
Buggy source:
/** 
 * Clone the actor into the specified workspace. This calls the base class and then resets the type constraints.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  FIR newObject=(FIR)(super.clone(workspace));
  newObject.taps.setTypeAtLeast(ArrayType.ARRAY_BOTTOM);
  newObject._initTypeConstraints();
  try {
    ArrayToken tapsToken=(ArrayToken)(newObject.taps.getToken());
    newObject._taps=tapsToken.arrayValue();
  }
 catch (  IllegalActionException throwable) {
    CloneNotSupportedException exception=new CloneNotSupportedException();
    exception.initCause(throwable);
    throw exception;
  }
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace. This calls the base class and then resets the type constraints.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  FIR newObject=(FIR)(super.clone(workspace));
  newObject.taps.setTypeAtLeast(ArrayType.ARRAY_BOTTOM);
  newObject._initTypeConstraints();
  newObject._taps=null;
  return newObject;
}
Program: 74240
Project: 74240
Buggy source:
/** 
 * Perform domain-specific initialization by calling the initialize(Actor) method of the director. The director may reject the actor by throwing an exception if the actor is incompatible with the domain. Set a flag that reinitializes the data buffer at the first firing.
 * @exception IllegalActionException If the superclass throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _data=null;
  _reinitializeNeeded=true;
}

Fixed version (ground truth):
/** 
 * Perform domain-specific initialization by calling the initialize(Actor) method of the director. The director may reject the actor by throwing an exception if the actor is incompatible with the domain. Set a flag that reinitializes the data buffer at the first firing.
 * @exception IllegalActionException If the superclass throws it.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _data=null;
  _initializeTaps();
}
Program: 74241
Project: 74241
Buggy source:
/** 
 * Invoke the wrapup() method of the superclass, and clear the event queue.
 * @exception IllegalActionException If the wrapup() method ofthe superclass throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  for (  Variable variable : _eventsListeningToVariables.keySet()) {
    variable.removeValueListener(this);
  }
  _eventQueue.clear();
  _eventsListeningToPorts.clear();
  _eventsListeningToVariables.clear();
  _initializedRefinements.clear();
  _refinementQueue.clear();
}

Fixed version (ground truth):
/** 
 * Invoke the wrapup() method of the superclass, and clear the event queue.
 * @exception IllegalActionException If the wrapup() method ofthe superclass throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  _clearState();
  for (  Variable variable : _eventsListeningToVariables.keySet()) {
    variable.removeValueListener(this);
  }
}
Program: 74242
Project: 74242
Buggy source:
/** 
 * Clear the state of this ERG director and the ERG directors of the refinements recursively, so that the event queues become empty.
 */
private void _clearState(){
  for (  TypedActor refinement : _initializedRefinements) {
    if (refinement instanceof ERGController) {
      ERGDirector director=((ERGController)refinement).director;
      director._clearState();
    }
  }
  _eventQueue.clear();
  _eventsListeningToPorts.clear();
  _eventsListeningToVariables.clear();
  _initializedRefinements.clear();
  _refinementQueue.clear();
}

Fixed version (ground truth):
/** 
 * Clear the state of this ERG director and the ERG directors of the refinements recursively, so that the event queues become empty.
 */
private void _clearState(){
  for (  TypedActor refinement : _initializedRefinements) {
    if (refinement instanceof ERGController) {
      ERGDirector director=((ERGController)refinement).director;
      director._clearState();
    }
  }
  _eventQueue.clear();
  _eventsListeningToPorts.clear();
  _eventsListeningToVariables.clear();
  _initializedRefinements.clear();
  _refinementQueue.clear();
  _delegateFireAt=false;
}
Program: 74245
Project: 74245
Buggy source:
/** 
 * Insert a new element after the specified element. If there is no such element, then append the new element to the end of the list.
 * @param name The element after which to insert the new element.
 * @param element The element to insert.
 * @exception IllegalActionException If the element to insert has no name.
 * @exception NameDuplicationException If the element to insert has aname that coincides with one already on the list.
 */
public void insertAfter(String name,Nameable element) throws IllegalActionException, NameDuplicationException {
  int index=_getIndexOf(name);
  if (index == -1) {
    append(element);
  }
 else {
    _insertAt((index + 1),element);
  }
  if (_hashEnabled) {
    _hashedList.put(name,element);
  }
}

Fixed version (ground truth):
/** 
 * Insert a new element after the specified element. If there is no such element, then append the new element to the end of the list.
 * @param name The element after which to insert the new element.
 * @param element The element to insert.
 * @exception IllegalActionException If the element to insert has no name.
 * @exception NameDuplicationException If the element to insert has aname that coincides with one already on the list.
 */
public void insertAfter(String name,Nameable element) throws IllegalActionException, NameDuplicationException {
  int index=_getIndexOf(name);
  if (index == -1) {
    append(element);
  }
 else {
    _insertAt((index + 1),element);
  }
  if (_hashEnabled) {
    _hashedList.put(element.getName(),element);
  }
}
Program: 74246
Project: 74246
Buggy source:
/** 
 * Insert a new element before the specified element. If there is no such element, then the insert the new element at the beginning of the list.
 * @param name The element before which to insert the new element.
 * @param element The element to insert.
 * @exception IllegalActionException If the element to insert has no name.
 * @exception NameDuplicationException If the element to insert has aname that coincides with one already on the list.
 */
public void insertBefore(String name,Nameable element) throws IllegalActionException, NameDuplicationException {
  int index=_getIndexOf(name);
  if (index == -1) {
    prepend(element);
  }
 else {
    _insertAt(index,element);
  }
  if (_hashEnabled) {
    _hashedList.put(name,element);
  }
}

Fixed version (ground truth):
/** 
 * Insert a new element before the specified element. If there is no such element, then the insert the new element at the beginning of the list.
 * @param name The element before which to insert the new element.
 * @param element The element to insert.
 * @exception IllegalActionException If the element to insert has no name.
 * @exception NameDuplicationException If the element to insert has aname that coincides with one already on the list.
 */
public void insertBefore(String name,Nameable element) throws IllegalActionException, NameDuplicationException {
  int index=_getIndexOf(name);
  if (index == -1) {
    prepend(element);
  }
 else {
    _insertAt(index,element);
  }
  if (_hashEnabled) {
    _hashedList.put(element.getName(),element);
  }
}
Program: 74247
Project: 74247
Buggy source:
/** 
 * Clone the library into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). If the library has not yet been populated, then the clone will also not have been populated.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If the library containslevel crossing transitions so that its connections cannot be cloned, or if one of the attributes cannot be cloned.
 * @return A new LazyTypedCompositeActor.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  _cloning=true;
  try {
    LazyTypedCompositeActor result=(LazyTypedCompositeActor)super.clone(workspace);
    result._cloning=false;
    return result;
  }
  finally {
    _cloning=false;
  }
}

Fixed version (ground truth):
/** 
 * Clone the library into the specified workspace. The new object is <i>not</i> added to the directory of that workspace (you must do this yourself if you want it there). If the library has not yet been populated, then the clone will also not have been populated.
 * @param workspace The workspace for the cloned object.
 * @exception CloneNotSupportedException If the library containslevel crossing transitions so that its connections cannot be cloned, or if one of the attributes cannot be cloned.
 * @return A new LazyTypedCompositeActor.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  _cloning=true;
  try {
    LazyTypedCompositeActor result=(LazyTypedCompositeActor)super.clone(workspace);
    result._base=null;
    result._configureDone=false;
    result._populating=false;
    result._configureSource=null;
    result._configureText=null;
    result._cloning=false;
    return result;
  }
  finally {
    _cloning=false;
  }
}
Program: 74250
Project: 74250
Buggy source:
private void _recordMirroredObjects(NamedObj pattern,NamedObj host){
  _matchResult.put(pattern,host);
  _replacementToHost.put(pattern,host);
  _patternToReplacement.put(pattern,pattern);
  for (  Object child : GTTools.getChildren(pattern,false,true,true,true)) {
    if (child instanceof Port) {
      Port port=(Port)child;
      _recordMirroredObjects(port,((Entity)host).getPort(port.getName()));
    }
 else     if (child instanceof Entity) {
      Entity entity=(Entity)child;
      _recordMirroredObjects(entity,((CompositeEntity)host).getEntity(entity.getName()));
    }
 else     if (child instanceof Relation) {
      Relation relation=(Relation)child;
      _recordMirroredObjects(relation,((CompositeEntity)host).getRelation(relation.getName()));
    }
  }
}

Fixed version (ground truth):
private void _recordMirroredObjects(NamedObj pattern,NamedObj host){
  _matchResult.put(pattern,host);
  _replacementToHost.put(pattern,host);
  _patternToReplacement.put(pattern,pattern);
  for (  Object child : GTTools.getChildren(pattern,false,true,true,true)) {
    if (child instanceof Port) {
      Port port=(Port)child;
      Port match=(Port)_matchResult.get(port);
      if (match == null) {
        match=((Entity)host).getPort(port.getName());
      }
      _recordMirroredObjects(port,match);
    }
 else     if (child instanceof Entity) {
      Entity entity=(Entity)child;
      Entity match=(Entity)_matchResult.get(entity);
      if (match == null) {
        match=((CompositeEntity)host).getEntity(entity.getName());
      }
      _recordMirroredObjects(entity,match);
    }
 else     if (child instanceof Relation) {
      Relation relation=(Relation)child;
      Relation match=(Relation)_matchResult.get(relation);
      if (match == null) {
        match=((CompositeEntity)host).getRelation(relation.getName());
      }
      _recordMirroredObjects(relation,match);
    }
  }
}
Program: 74251
Project: 74251
Buggy source:
public V put(K key,V value){
  if (!super.containsKey(key)) {
    _keySequence.add(key);
  }
  return super.put(key,value);
}

Fixed version (ground truth):
public V put(K key,V value){
  if (value != null && !super.containsKey(key)) {
    _keySequence.add(key);
  }
  return super.put(key,value);
}
Program: 74252
Project: 74252
Buggy source:
public V put(K key,V value){
  V oldValue=super.put(key,value);
  _reverseMap.put(value,key);
  return oldValue;
}

Fixed version (ground truth):
public V put(K key,V value){
  if (value == null) {
    return remove(key);
  }
 else {
    V oldValue=super.put(key,value);
    _reverseMap.put(value,key);
    return oldValue;
  }
}
Program: 74253
Project: 74253
Buggy source:
/** 
 * React to a debug message.
 * @param message The debug message.
 */
public void message(String message){
  try {
    Tableau tableau=(Tableau)((ObjectToken)getToken()).getValue();
    TextEditor frame=(TextEditor)tableau.getFrame();
    frame.text.append(message + "String_Node_Str");
  }
 catch (  Throwable e) {
    throw new InternalErrorException(this,e,"String_Node_Str" + "String_Node_Str" + message + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * React to a debug message.
 * @param message The debug message.
 */
public void message(String message){
  try {
    Tableau tableau=(Tableau)((ObjectToken)getToken()).getValue();
    if (tableau != null) {
      TextEditor frame=(TextEditor)tableau.getFrame();
      frame.text.append(message + "String_Node_Str");
    }
  }
 catch (  Throwable e) {
    throw new InternalErrorException(this,e,"String_Node_Str" + "String_Node_Str" + message + "String_Node_Str");
  }
}
Program: 74254
Project: 74254
Buggy source:
public void run(){
  tableau.close();
}

Fixed version (ground truth):
public void run(){
  tableau.close();
  Effigy effigy=(Effigy)tableau.getContainer();
  if (effigy != null) {
    try {
      effigy.setContainer(null);
    }
 catch (    KernelException e) {
    }
  }
}
Program: 74255
Project: 74255
Buggy source:
public void initialize() throws IllegalActionException {
  final Tableau tableau=(Tableau)((ObjectToken)getToken()).getValue();
  if (tableau != null) {
    setToken(new ObjectToken(null,Tableau.class));
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        tableau.close();
      }
    }
);
  }
}

Fixed version (ground truth):
public void initialize() throws IllegalActionException {
  final Tableau tableau=(Tableau)((ObjectToken)getToken()).getValue();
  if (tableau != null) {
    setToken(new ObjectToken(null,Tableau.class));
    SwingUtilities.invokeLater(new Runnable(){
      public void run(){
        tableau.close();
        Effigy effigy=(Effigy)tableau.getContainer();
        if (effigy != null) {
          try {
            effigy.setContainer(null);
          }
 catch (          KernelException e) {
          }
        }
      }
    }
);
  }
}
Program: 74256
Project: 74256
Buggy source:
public Token get(String name) throws IllegalActionException {
  NamedObj patternChild=GTTools.getChild(_pattern,name,false,true,true,true);
  if (patternChild != null && _matchResult.containsKey(patternChild)) {
    NamedObj child=(NamedObj)_matchResult.get(patternChild);
    return new ObjectToken(child,child.getClass());
  }
 else {
    Token token=_superscope.get(name);
    if (token == null) {
      NamedObj container=_pattern.getContainer();
      if (container != null) {
        NamedObjVariable containerVar=NamedObjVariable.getNamedObjVariable(_pattern.getContainer(),true);
        ParserScope containerScope=containerVar.getParserScope();
        token=containerScope.get(name);
        return token;
      }
    }
    if (token instanceof ObjectToken) {
      Object value=((ObjectToken)token).getValue();
      if (value instanceof Port || value instanceof Entity || value instanceof Relation) {
        return ObjectToken.NULL;
      }
    }
    return token;
  }
}

Fixed version (ground truth):
public Token get(String name) throws IllegalActionException {
  NamedObj patternChild=GTTools.getChild(_pattern,name,false,true,true,true);
  if (patternChild != null && _matchResult.containsKey(patternChild)) {
    NamedObj child=(NamedObj)_matchResult.get(patternChild);
    return new ObjectToken(child,child.getClass());
  }
 else {
    Token token=_superscope.get(name);
    if (token == null) {
      NamedObj container=_pattern.getContainer();
      if (container != null) {
        NamedObjVariable containerVar=NamedObjVariable.getNamedObjVariable(container,true);
        ParserScope containerScope=containerVar.getParserScope();
        token=containerScope.get(name);
        return token;
      }
    }
    if (token instanceof ObjectToken) {
      Object value=((ObjectToken)token).getValue();
      if (value instanceof Port || value instanceof Entity || value instanceof Relation) {
        return ObjectToken.NULL;
      }
    }
    return token;
  }
}
Program: 74262
Project: 74262
Buggy source:
public RefiringData fire(ArrayToken arguments) throws IllegalActionException {
  RefiringData data=super.fire(arguments);
  CompositeEntity model=getModelParameter().getModel();
  model.setDeferringChangeRequests(false);
  boolean isMatched=mode.transform(mode.getWorkingCopy(_transformation),model);
  getModelParameter().setModel(model);
  matched.setToken(BooleanToken.getInstance(isMatched));
  return data;
}

Fixed version (ground truth):
public RefiringData fire(ArrayToken arguments) throws IllegalActionException {
  RefiringData data=super.fire(arguments);
  CompositeEntity model=getModelParameter().getModel();
  model.setDeferringChangeRequests(false);
  boolean isMatched=false;
  try {
    isMatched=mode.transform(mode.getWorkingCopy(_transformation),model);
  }
 catch (  Throwable t) {
    throw new IllegalActionException(this,t,"String_Node_Str" + "String_Node_Str" + getFullName() + "String_Node_Str");
  }
  getModelParameter().setModel(model);
  matched.setToken(BooleanToken.getInstance(isMatched));
  return data;
}
Program: 74264
Project: 74264
Buggy source:
public void setDocumentation(String documentation){
  setExpression(getExpression(_method,_attributeName,_modifiedDate,_unit,documentation));
}

Fixed version (ground truth):
public void setDocumentation(String documentation){
  setExpression(formatExpression(_method,_attributeName,_modifiedDate,_unit,documentation));
}
Program: 74265
Project: 74265
Buggy source:
public void setAttributeName(String name){
  setExpression(getExpression(_method,name,_modifiedDate,_unit,_documentation));
}

Fixed version (ground truth):
public void setAttributeName(String name){
  setExpression(formatExpression(_method,name,_modifiedDate,_unit,_documentation));
}
Program: 74266
Project: 74266
Buggy source:
public void setMethod(Method method){
  setExpression(getExpression(method,_attributeName,_modifiedDate,_unit,_documentation));
}

Fixed version (ground truth):
public void setMethod(Method method){
  setExpression(formatExpression(method,_attributeName,_modifiedDate,_unit,_documentation));
}
Program: 74267
Project: 74267
Buggy source:
public void setModifiedDate(Date date){
  setExpression(getExpression(_method,_attributeName,date,_unit,_documentation));
}

Fixed version (ground truth):
public void setModifiedDate(Date date){
  setExpression(formatExpression(_method,_attributeName,date,_unit,_documentation));
}
Program: 74268
Project: 74268
Buggy source:
public void setUnit(String unit){
  setExpression(getExpression(_method,_attributeName,_modifiedDate,unit,_documentation));
}

Fixed version (ground truth):
public void setUnit(String unit){
  setExpression(formatExpression(_method,_attributeName,_modifiedDate,unit,_documentation));
}
Program: 74269
Project: 74269
Buggy source:
public void setExpression(String expr){
  if (expr == null || expr.equals("String_Node_Str")) {
    expr="String_Node_Str" + DATE_FORMAT.format(new Date()) + "String_Node_Str";
  }
  super.setExpression(expr);
}

Fixed version (ground truth):
public void setExpression(String expr){
  if (expr == null || expr.equals("String_Node_Str")) {
    expr="String_Node_Str" + new SimpleDateFormat(DATE_FORMAT).format(new Date()) + "String_Node_Str";
  }
  super.setExpression(expr);
}
Program: 74270
Project: 74270
Buggy source:
public void changeExecuted(ChangeRequest change){
  if (change instanceof MoMLChangeRequest) {
    NamedObj container=getContainer();
    if (container != null && container.getContainer() == ((MoMLChangeRequest)change).getContext()) {
      String expression=StringUtilities.unescapeForXML(getExpression(_method,_attributeName,new Date(),_unit,_documentation));
      String moml="String_Node_Str" + getName() + "String_Node_Str"+ expression+ "String_Node_Str";
      MoMLChangeRequest request=new MoMLChangeRequest(this,container,moml);
      request.setUndoable(true);
      request.setMergeWithPreviousUndo(true);
      container.requestChange(request);
    }
  }
}

Fixed version (ground truth):
public void changeExecuted(ChangeRequest change){
  if (change instanceof MoMLChangeRequest) {
    NamedObj container=getContainer();
    if (container != null && container.getContainer() == ((MoMLChangeRequest)change).getContext()) {
      String expression=StringUtilities.unescapeForXML(formatExpression(_method,_attributeName,new Date(),_unit,_documentation));
      String moml="String_Node_Str" + getName() + "String_Node_Str"+ expression+ "String_Node_Str";
      MoMLChangeRequest request=new MoMLChangeRequest(this,container,moml);
      request.setUndoable(true);
      request.setMergeWithPreviousUndo(true);
      container.requestChange(request);
    }
  }
}
Program: 74271
Project: 74271
Buggy source:
public Collection<?> validate() throws IllegalActionException {
  String expression=getExpression();
  Matcher matcher=_PATTERN.matcher(expression);
  if (!matcher.matches()) {
    throw new IllegalActionException(this,"String_Node_Str" + expression);
  }
  String method=matcher.group(1);
  if (method.equals("String_Node_Str")) {
    _method=Method.GET;
  }
 else   if (method.equals("String_Node_Str")) {
    _method=Method.PUT;
  }
 else   if (method.equals("String_Node_Str")) {
    _method=Method.SYNC;
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + method);
  }
  _attributeName=matcher.group(2);
  try {
    _modifiedDate=DATE_FORMAT.parse(matcher.group(3));
  }
 catch (  ParseException e) {
    throw new IllegalActionException(this,e,"String_Node_Str" + expression);
  }
  _unit=matcher.group(4);
  _documentation=matcher.group(5);
  return super.validate();
}

Fixed version (ground truth):
public Collection<?> validate() throws IllegalActionException {
  String expression=getExpression();
  Matcher matcher=_PATTERN.matcher(expression);
  if (!matcher.matches()) {
    throw new IllegalActionException(this,"String_Node_Str" + expression);
  }
  String method=matcher.group(1);
  if (method.equals("String_Node_Str")) {
    _method=Method.GET;
  }
 else   if (method.equals("String_Node_Str")) {
    _method=Method.PUT;
  }
 else   if (method.equals("String_Node_Str")) {
    _method=Method.SYNC;
  }
 else {
    throw new IllegalActionException(this,"String_Node_Str" + method);
  }
  _attributeName=matcher.group(2);
  try {
    _modifiedDate=new SimpleDateFormat(DATE_FORMAT).parse(matcher.group(3));
  }
 catch (  ParseException e) {
    throw new IllegalActionException(this,e,"String_Node_Str" + expression);
  }
  _unit=matcher.group(4);
  _documentation=matcher.group(5);
  return super.validate();
}
Program: 74272
Project: 74272
Buggy source:
/** 
 * Return the function result.
 * @return A Type.
 * @exception IllegalActionException If inferring types for theexpression fails.
 */
public Object getValue() throws IllegalActionException {
  try {
    InequalityTerm[] terms=getVariables();
    for (int i=0; i < terms.length; i++) {
      InequalityTerm term=terms[i];
      if ((term != this) && (term.getValue() == BaseType.UNKNOWN)) {
        return BaseType.UNKNOWN;
      }
    }
    int index=_destinationNames.indexOf(_name);
    ASTPtRootNode parseTree=(ASTPtRootNode)_parseTrees.get(index);
    Type type=_typeInference.inferTypes(parseTree,_getParserScope());
    NamedObj container=getContainer();
    while (container != null && !(container instanceof Entity)) {
      container=container.getContainer();
    }
    if (container != null && ((Entity)container).getPort(_name) == null) {
      if (_numbers.get(index) != null) {
        ArrayType arrayType=new ArrayType(type);
        return arrayType;
      }
    }
    return type;
  }
 catch (  Exception ex) {
    throw new IllegalActionException(AbstractActionsAttribute.this,ex,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Return the function result.
 * @return A Type.
 * @exception IllegalActionException If inferring types for theexpression fails.
 */
public Object getValue() throws IllegalActionException {
  try {
    InequalityTerm[] terms=getVariables();
    for (int i=0; i < terms.length; i++) {
      InequalityTerm term=terms[i];
      if ((term != this) && (term.getValue() == BaseType.UNKNOWN)) {
        return BaseType.UNKNOWN;
      }
    }
    int index=_destinationNames.indexOf(_name);
    ASTPtRootNode parseTree=(ASTPtRootNode)_parseTrees.get(index);
    Type type=_typeInference.inferTypes(parseTree,_getParserScope());
    NamedObj container=getContainer();
    while (container != null && !(container instanceof Entity)) {
      container=container.getContainer();
    }
    if (container != null && ((Entity)container).getPort(_name) == null) {
      if (_numbers.get(index) != null && (getDestination(_name) instanceof Variable)) {
        ArrayType arrayType=new ArrayType(type);
        return arrayType;
      }
    }
    return type;
  }
 catch (  Exception ex) {
    throw new IllegalActionException(AbstractActionsAttribute.this,ex,"String_Node_Str");
  }
}
Program: 74273
Project: 74273
Buggy source:
/** 
 * Create an instance of a model and convert it.
 * @param args The command-line arguments providing the numberof entities threshold and naming the .xml file to convert.
 */
public static void main(String[] args){
  try {
    if (args.length == 0) {
      System.err.println("String_Node_Str");
      return;
    }
    if (args.length == 1) {
      new ConvertToLazy(args[0],100);
      return;
    }
    int threshold=Integer.parseInt(args[1]);
    new ConvertToLazy(args[0],threshold);
  }
 catch (  Throwable ex) {
    System.err.println("String_Node_Str" + ex);
    ex.printStackTrace();
  }
}

Fixed version (ground truth):
/** 
 * Create an instance of a model and convert it.
 * @param args The command-line arguments providing the numberof entities threshold and naming the .xml file to convert.
 */
public static void main(String[] args){
  try {
    if (args.length == 0) {
      System.err.println("String_Node_Str");
      return;
    }
    if (args.length == 1) {
      new ConvertToLazy(args[0],10);
      return;
    }
    int threshold=Integer.parseInt(args[1]);
    new ConvertToLazy(args[0],threshold);
  }
 catch (  Throwable ex) {
    System.err.println("String_Node_Str" + ex);
    ex.printStackTrace();
  }
}
Program: 74274
Project: 74274
Buggy source:
/** 
 * Convert the model.
 * @param actor The model to convert.
 * @param threshold The threshold to use.
 */
public void convert(TypedCompositeActor actor,int threshold){
  List<ComponentEntity> entities=actor.entityList();
  for (  ComponentEntity entity : entities) {
    if (entity instanceof TypedCompositeActor) {
      convert((TypedCompositeActor)entity,threshold);
      if (count((TypedCompositeActor)entity) >= threshold) {
        entity.setClassName("String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Convert the model.
 * @param actor The model to convert.
 * @param threshold The threshold to use.
 */
public void convert(TypedCompositeActor actor,int threshold){
  List<ComponentEntity> entities=actor.entityList();
  for (  ComponentEntity entity : entities) {
    if (entity instanceof TypedCompositeActor) {
      convert((TypedCompositeActor)entity,threshold);
      if (entity.getClassName().equals("String_Node_Str") && count((TypedCompositeActor)entity) >= threshold) {
        entity.setClassName("String_Node_Str");
      }
    }
  }
  List<ComponentEntity> classDefinitions=actor.classDefinitionList();
  for (  ComponentEntity classDefinition : classDefinitions) {
    if (classDefinition instanceof TypedCompositeActor) {
      convert((TypedCompositeActor)classDefinition,threshold);
      if (classDefinition.getClassName().equals("String_Node_Str") && count((TypedCompositeActor)classDefinition) >= threshold) {
        classDefinition.setClassName("String_Node_Str");
      }
    }
  }
}
Program: 74275
Project: 74275
Buggy source:
/** 
 * Initialize this controller by initializing the director that it contains, which sets the initial events, and initializing all the refinements.
 * @exception IllegalActionException If the director or initialize() of thesuperclass throws it.
 */
public void initialize() throws IllegalActionException {
  director.initialize();
  super.initialize();
  Iterator<?> entities=deepEntityList().iterator();
  while (entities.hasNext()) {
    Event event=(Event)entities.next();
    TypedActor[] refinements=event.getRefinement();
    if (refinements != null) {
      for (      TypedActor refinement : refinements) {
        refinement.initialize();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Initialize this controller by initializing the director that it contains, which sets the initial events, and initializing all the refinements.
 * @exception IllegalActionException If the director or initialize() of thesuperclass throws it.
 */
public void initialize() throws IllegalActionException {
  director.initialize();
  super.initialize();
}
Program: 74276
Project: 74276
Buggy source:
/** 
 * Cancel an event that was previously scheduled in the event queue. This method can be called by an event that has an outgoing canceling edge (a  {@link SchedulingRelation} object with the canceling attribute set totrue.
 * @param event The event to be cancelled.
 * @return The model time at which the cancelled event was previouslyscheduled, if that event is found in the event queue. If the event is not found, the return is null.
 * @exception IllegalActionException If the refinement of the given event(if any) cannot be obtained.
 */
public TimedEvent cancel(Event event) throws IllegalActionException {
  TimedEvent timedEvent=findFirst(event,true);
  if (timedEvent != null) {
    _eventQueue.remove(timedEvent);
    _refinementQueue.remove(timedEvent);
    for (    Set<TimedEvent> set : _eventsListeningToPorts.values()) {
      set.remove(timedEvent);
    }
    for (    Set<TimedEvent> set : _eventsListeningToVariables.values()) {
      set.remove(timedEvent);
    }
  }
  return timedEvent;
}

Fixed version (ground truth):
/** 
 * Cancel an event that was previously scheduled in the event queue. This method can be called by an event that has an outgoing canceling edge (a  {@link SchedulingRelation} object with the canceling attribute set totrue.
 * @param event The event to be cancelled.
 * @return The model time at which the cancelled event was previouslyscheduled, if that event is found in the event queue. If the event is not found, the return is null.
 * @exception IllegalActionException If the refinement of the given event(if any) cannot be obtained.
 */
public TimedEvent cancel(Event event) throws IllegalActionException {
  TimedEvent timedEvent=findFirst(event,true);
  if (timedEvent != null) {
    _eventQueue.remove(timedEvent);
    _refinementQueue.remove(timedEvent);
    Object contents=timedEvent.contents;
    if (contents instanceof TypedActor) {
      _initializedRefinements.remove(contents);
      if (contents instanceof ERGController) {
        ((ERGController)contents).director._clearState();
      }
    }
    for (    Set<TimedEvent> set : _eventsListeningToPorts.values()) {
      set.remove(timedEvent);
    }
    for (    Set<TimedEvent> set : _eventsListeningToVariables.values()) {
      set.remove(timedEvent);
    }
  }
  return timedEvent;
}
Program: 74277
Project: 74277
Buggy source:
/** 
 * Invoke the wrapup() method of the superclass, and clear the event queue.
 * @exception IllegalActionException If the wrapup() method ofthe superclass throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  for (  Variable variable : _eventsListeningToVariables.keySet()) {
    variable.removeValueListener(this);
  }
  _eventQueue.clear();
  _eventsListeningToPorts.clear();
  _eventsListeningToVariables.clear();
  _refinementQueue.clear();
}

Fixed version (ground truth):
/** 
 * Invoke the wrapup() method of the superclass, and clear the event queue.
 * @exception IllegalActionException If the wrapup() method ofthe superclass throws it.
 */
public void wrapup() throws IllegalActionException {
  super.wrapup();
  for (  Variable variable : _eventsListeningToVariables.keySet()) {
    variable.removeValueListener(this);
  }
  _eventQueue.clear();
  _eventsListeningToPorts.clear();
  _eventsListeningToVariables.clear();
  _initializedRefinements.clear();
  _refinementQueue.clear();
}