nus-yam/ex-repair huggingface dataset:
Program: 74935
Project: 74935
Buggy source:
/** 
 * Construct a frame associated with the specified case actor. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This is typically done by calling show() on the controlling tableau. This constructor results in a graph frame that obtains its library either from the model (if it has one), or the <i>defaultLibrary</i> argument (if it is non-null), or the default library defined in the configuration.
 * @see Tableau#show()
 * @param entity The model to put in this frame.
 * @param tableau The tableau responsible for this frame.
 * @param defaultLibrary An attribute specifying the default libraryto use if the model does not have a library.
 */
public CaseGraphFrame(Case entity,Tableau tableau,LibraryAttribute defaultLibrary){
  super(entity,tableau,defaultLibrary);
  _case=entity;
  _addCaseAction=new AddCaseAction();
}

Fixed version (ground truth):
/** 
 * Construct a frame associated with the specified case actor. After constructing this, it is necessary to call setVisible(true) to make the frame appear. This is typically done by calling show() on the controlling tableau. This constructor results in a graph frame that obtains its library either from the model (if it has one), or the <i>defaultLibrary</i> argument (if it is non-null), or the default library defined in the configuration.
 * @see Tableau#show()
 * @param entity The model to put in this frame.
 * @param tableau The tableau responsible for this frame.
 * @param defaultLibrary An attribute specifying the default libraryto use if the model does not have a library.
 */
public CaseGraphFrame(Case entity,Tableau tableau,LibraryAttribute defaultLibrary){
  super(entity,tableau,defaultLibrary);
  _case=entity;
  _addCaseAction=new AddCaseAction();
  _removeCaseAction=new RemoveCaseAction();
}
Program: 74936
Project: 74936
Buggy source:
/** 
 * React to a change in the state of the tabbed pane.
 * @param event The event.
 */
public void stateChanged(ChangeEvent event){
  Object source=event.getSource();
  if (source instanceof JTabbedPane) {
    Component selected=((JTabbedPane)source).getSelectedComponent();
    if (selected instanceof JGraph) {
      setJGraph((JGraph)selected);
    }
  }
}

Fixed version (ground truth):
/** 
 * React to a change in the state of the tabbed pane.
 * @param event The event.
 */
public void stateChanged(ChangeEvent event){
  Object source=event.getSource();
  if (source instanceof JTabbedPane) {
    Component selected=((JTabbedPane)source).getSelectedComponent();
    if (selected instanceof JGraph) {
      setJGraph((JGraph)selected);
    }
    if (_graphPanner != null) {
      _graphPanner.setCanvas((JGraph)selected);
      _graphPanner.repaint();
    }
  }
}
Program: 74937
Project: 74937
Buggy source:
/** 
 * Create the component that goes to the right of the library. NOTE: This is called in the base class constructor, before things have been initialized. Hence, it cannot reference local variables.
 * @param entity The entity to display in the component.
 * @return The component that goes to the right of the library.
 */
protected JComponent _createRightComponent(NamedObj entity){
  if (!(entity instanceof Case)) {
    return super._createRightComponent(entity);
  }
  JTabbedPane tabbedPane=new JTabbedPane();
  tabbedPane.addChangeListener(this);
  Iterator cases=((Case)entity).entityList(Refinement.class).iterator();
  while (cases.hasNext()) {
    Refinement refinement=(Refinement)cases.next();
    GraphPane pane=_createGraphPane(refinement);
    pane.getForegroundLayer().setPickHalo(2);
    pane.getForegroundEventLayer().setConsuming(false);
    pane.getForegroundEventLayer().setEnabled(true);
    pane.getForegroundEventLayer().addLayerListener(new LayerAdapter(){
      /** 
 * Invoked when the mouse is pressed on a layer or figure.
 */
      public void mousePressed(      LayerEvent event){
        Component component=event.getComponent();
        if (!component.hasFocus()) {
          component.requestFocus();
        }
      }
    }
);
    JGraph jgraph=new JGraph(pane);
    tabbedPane.add(refinement.getName(),jgraph);
    setJGraph(jgraph);
    jgraph.setBackground(BACKGROUND_COLOR);
    new EditorDropTarget(jgraph);
  }
  return tabbedPane;
}

Fixed version (ground truth):
/** 
 * Create the component that goes to the right of the library. NOTE: This is called in the base class constructor, before things have been initialized. Hence, it cannot reference local variables.
 * @param entity The entity to display in the component.
 * @return The component that goes to the right of the library.
 */
protected JComponent _createRightComponent(NamedObj entity){
  if (!(entity instanceof Case)) {
    return super._createRightComponent(entity);
  }
  _tabbedPane=new JTabbedPane();
  _tabbedPane.addChangeListener(this);
  Iterator cases=((Case)entity).entityList(Refinement.class).iterator();
  boolean first=true;
  while (cases.hasNext()) {
    Refinement refinement=(Refinement)cases.next();
    JGraph jgraph=_addTabbedPane(refinement,false);
    if (first) {
      first=false;
      setJGraph(jgraph);
    }
  }
  return _tabbedPane;
}
Program: 74938
Project: 74938
Buggy source:
protected void _execute() throws Exception {
  super._execute();
  Entity defaultRefinement=_case.getEntity("String_Node_Str");
  if (defaultRefinement != null) {
    defaultRefinement.moveToLast();
  }
  Entity entity=_case.getEntity(pattern);
  Iterator ports=_case.portList().iterator();
  while (ports.hasNext()) {
    Port port=(Port)ports.next();
    if (port == _case.control.getPort()) {
      continue;
    }
    try {
      if (entity instanceof Refinement) {
        ((Refinement)entity).setMirrorDisable(true);
      }
 else       if (entity instanceof ModalController) {
        ((ModalController)entity).setMirrorDisable(true);
      }
      Port newPort=entity.newPort(port.getName());
      if (newPort instanceof RefinementPort && port instanceof IOPort) {
        try {
          ((RefinementPort)newPort).setMirrorDisable(true);
          if (((IOPort)port).isInput()) {
            ((RefinementPort)newPort).setInput(true);
          }
          if (((IOPort)port).isOutput()) {
            ((RefinementPort)newPort).setOutput(true);
          }
          if (((IOPort)port).isMultiport()) {
            ((RefinementPort)newPort).setMultiport(true);
          }
        }
  finally {
          ((RefinementPort)newPort).setMirrorDisable(false);
        }
      }
    }
  finally {
      if (entity instanceof Refinement) {
        ((Refinement)entity).setMirrorDisable(false);
      }
 else       if (entity instanceof ModalController) {
        ((ModalController)entity).setMirrorDisable(false);
      }
    }
  }
}

Fixed version (ground truth):
protected void _execute() throws Exception {
  super._execute();
  int count=_tabbedPane.getTabCount();
  for (int i=0; i < count; i++) {
    if (name.equals(_tabbedPane.getTitleAt(i))) {
      _tabbedPane.remove(i);
      break;
    }
  }
}
Program: 74939
Project: 74939
Buggy source:
/** 
 * Get the UndoStackAttribute associated with the given object. This is done by searching up the containment hierarchy until such an attribute is found. If no such attribute is found, then create and attach a new one to the top level. This method gets read access on the workspace associated with the specified object.
 * @param object The model for which an undo stack is required(must not be null or a NullPointerException will the thrown).
 * @return The current undo stack attribute if there is one, or a new one.
 */
public static UndoStackAttribute getUndoInfo(final NamedObj object){
  try {
    object.workspace().getReadAccess();
    NamedObj topLevel=object.toplevel();
    NamedObj container=object;
    while (container != null) {
      List attrList=object.attributeList(UndoStackAttribute.class);
      if (attrList.size() > 0) {
        return (UndoStackAttribute)attrList.get(0);
      }
      container=(NamedObj)container.getContainer();
    }
    try {
      return new UndoStackAttribute(topLevel,"String_Node_Str");
    }
 catch (    KernelException e) {
      throw new InternalErrorException(e);
    }
  }
  finally {
    object.workspace().doneReading();
  }
}

Fixed version (ground truth):
/** 
 * Get the UndoStackAttribute associated with the given object. This is done by searching up the containment hierarchy until such an attribute is found. If no such attribute is found, then create and attach a new one to the top level. This method gets read access on the workspace associated with the specified object.
 * @param object The model for which an undo stack is required(must not be null or a NullPointerException will the thrown).
 * @return The current undo stack attribute if there is one, or a new one.
 */
public static UndoStackAttribute getUndoInfo(final NamedObj object){
  try {
    object.workspace().getReadAccess();
    NamedObj topLevel=object.toplevel();
    NamedObj container=object;
    while (container != null) {
      List attrList=container.attributeList(UndoStackAttribute.class);
      if (attrList.size() > 0) {
        return (UndoStackAttribute)attrList.get(0);
      }
      container=(NamedObj)container.getContainer();
    }
    try {
      return new UndoStackAttribute(topLevel,"String_Node_Str");
    }
 catch (    KernelException e) {
      throw new InternalErrorException(e);
    }
  }
  finally {
    object.workspace().doneReading();
  }
}
Program: 74940
Project: 74940
Buggy source:
/** 
 * Returns an iterator of (some or all) transitions from the given state.
 * @param The given state.
 * @return An iterator of (some or all) transitions from the given state. 
 */
public Iterator retrieveTransitions(State state);

Fixed version (ground truth):
/** 
 * Returns an iterator of (some or all) transitions from the given state.
 * @param state The given state.
 * @return An iterator of (some or all) transitions from thegiven state.
 */
public Iterator retrieveTransitions(State state);
Program: 74941
Project: 74941
Buggy source:
/** 
 * Generate code for updating current state of this FSMActor. The states are numbered according to the order in the list returned by entityList().
 * @param codeBuffer The string buffer that the generated code is appended to.
 * @param state The current state.
 * @param depth The depth in the hierarchy, to determine indenting.
 */
protected void _updateCurrentState(StringBuffer codeBuffer,State state,int depth){
  ptolemy.domains.fsm.kernel.FSMActor fsmActor=(ptolemy.domains.fsm.kernel.FSMActor)getComponent();
  Iterator states=fsmActor.entityList().iterator();
  int stateCounter=0;
  while (states.hasNext()) {
    if (states.next() == state) {
      codeBuffer.append("String_Node_Str" + stateCounter + "String_Node_Str");
      break;
    }
    stateCounter++;
  }
}

Fixed version (ground truth):
/** 
 * Generate code for updating current state of this FSMActor. The states are numbered according to the order in the list returned by entityList().
 * @param codeBuffer The string buffer that the generated code isappended to.
 * @param state The current state.
 * @param depth The depth in the hierarchy, to determine indenting.
 */
protected void _updateCurrentState(StringBuffer codeBuffer,State state,int depth){
  ptolemy.domains.fsm.kernel.FSMActor fsmActor=(ptolemy.domains.fsm.kernel.FSMActor)getComponent();
  Iterator states=fsmActor.entityList().iterator();
  int stateCounter=0;
  while (states.hasNext()) {
    if (states.next() == state) {
      codeBuffer.append("String_Node_Str" + stateCounter + "String_Node_Str");
      break;
    }
    stateCounter++;
  }
}
Program: 74942
Project: 74942
Buggy source:
/** 
 * Generate the fire code of the associated FSMActor.  It provies  generateTransitionCode(StringBuffer, TransitionRetriever) with an anonymous class implementing a method which returns an iterator of all outgoing transitions of the current state. 
 * @return The generated fire code.
 * @exception IllegalActionException If thrown while generating firing code.
 */
public String generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generateFireCode());
  generateTransitionCode(code,new TransitionRetriever(){
    public Iterator retrieveTransitions(    State state){
      return state.outgoingPort.linkedRelationList().iterator();
    }
  }
);
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the fire code of the associated FSMActor.  It provies  generateTransitionCode(StringBuffer, TransitionRetriever) with an anonymous class implementing a method which returns an iterator of all outgoing transitions of the current state. 
 * @return The generated fire code.
 * @exception IllegalActionException If thrown while generatingfiring code.
 */
public String generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generateFireCode());
  generateTransitionCode(code,new TransitionRetriever(){
    public Iterator retrieveTransitions(    State state){
      return state.outgoingPort.linkedRelationList().iterator();
    }
  }
);
  return code.toString();
}
Program: 74943
Project: 74943
Buggy source:
/** 
 * Generate the initialize code of the associated FSMActor. It generates code for initializing current state with initial state,  and initializing current configuration of the container when it applies (i.e., when this FSMActor works as a modal controller for a MultirateFSMDirector).  
 * @return The initialize code of the associated FSMActor.
 * @exception IllegalActionException If initial state cannot be found,configuraton number cannot be updated or code cannot be processed.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer codeBuffer=new StringBuffer();
  codeBuffer.append(super.generateInitializeCode());
  ptolemy.domains.fsm.kernel.FSMActor fsmActor=(ptolemy.domains.fsm.kernel.FSMActor)getComponent();
  State initialState=fsmActor.getInitialState();
  _updateCurrentState(codeBuffer,initialState,0);
  return processCode(codeBuffer.toString());
}

Fixed version (ground truth):
/** 
 * Generate the initialize code of the associated FSMActor. It generates code for initializing current state with initial state, and initializing current configuration of the container when it applies (i.e., when this FSMActor works as a modal controller for a MultirateFSMDirector).
 * @return The initialize code of the associated FSMActor.
 * @exception IllegalActionException If initial state cannot be found,configuraton number cannot be updated or code cannot be processed.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer codeBuffer=new StringBuffer();
  codeBuffer.append(super.generateInitializeCode());
  ptolemy.domains.fsm.kernel.FSMActor fsmActor=(ptolemy.domains.fsm.kernel.FSMActor)getComponent();
  State initialState=fsmActor.getInitialState();
  _updateCurrentState(codeBuffer,initialState,0);
  return processCode(codeBuffer.toString());
}
Program: 74946
Project: 74946
Buggy source:
protected void _execute() throws Exception {
  super._execute();
  NamedObj sample=null;
  String name=rootName;
  if (target != null) {
    name=target.getName();
  }
  if (manager.isTargetInstantiableAttribute()) {
    sample=container.getAttribute(name);
  }
 else   if (manager.isTargetInstantiableEntity()) {
    sample=container.getEntity(name);
  }
 else   if (manager.isTargetInstantiablePort()) {
    sample=container.getPort(name);
  }
  if (sample != null) {
    _populatePortsAndParametersTable(sample,manager);
    _adjustIconDisplay(sample,container,graphPane,jgraph);
  }
}

Fixed version (ground truth):
protected void _execute() throws Exception {
  super._execute();
  NamedObj sample=null;
  String name=rootName;
  if (target != null) {
    name=target.getName();
  }
  if (manager.isTargetInstantiableAttribute()) {
    sample=_iconContainer.getAttribute(name);
  }
 else   if (manager.isTargetInstantiableEntity()) {
    sample=_iconContainer.getEntity(name);
  }
 else   if (manager.isTargetInstantiablePort()) {
    sample=_iconContainer.getPort(name);
  }
  if (sample != null) {
    _populatePortsAndParametersTable(sample,manager);
    _adjustIconDisplay(sample,_iconContainer,_graphPane,_jgraph);
  }
}
Program: 74947
Project: 74947
Buggy source:
/** 
 * Remove any listeners we have created. The frame displaying this graph model should call this function when the frame is closed.
 */
public void removeListeners(){
  _composite.removeChangeListener(_graphChangeListener);
}

Fixed version (ground truth):
/** 
 * Remove any listeners we have created. The frame displaying this graph model should call this function when the frame is closed.
 */
public void removeListeners(){
  _composite.removeChangeListener(this);
}
Program: 74948
Project: 74948
Buggy source:
/** 
 * Notify the listener that the change has failed with the specified exception.
 * @param change The change that has failed.
 * @param exception The exception that was thrown.
 */
public void changeFailed(ChangeRequest change,Exception exception){
  if (change == null) {
    MessageHandler.error("String_Node_Str",exception);
  }
 else   if (!change.isErrorReported()) {
    change.setErrorReported(true);
    MessageHandler.error("String_Node_Str",exception);
  }
  if (_update()) {
    dispatchGraphEvent(new GraphEvent(AbstractBasicGraphModel.this,GraphEvent.STRUCTURE_CHANGED,getRoot()));
  }
}

Fixed version (ground truth):
/** 
 * Notify the listener that the change has failed with the specified exception.
 * @param change The change that has failed.
 * @param exception The exception that was thrown.
 */
public void changeFailed(ChangeRequest change,Exception exception){
  if (change == null) {
    MessageHandler.error("String_Node_Str",exception);
  }
 else   if (!change.isErrorReported()) {
    change.setErrorReported(true);
    MessageHandler.error("String_Node_Str",exception);
  }
  if (_update()) {
    dispatchGraphEvent(new GraphEvent(this,GraphEvent.STRUCTURE_CHANGED,getRoot()));
  }
}
Program: 74949
Project: 74949
Buggy source:
/** 
 * Create a graph model for the specified Ptolemy II model. Note that the argument need not be a CompositeEntity, although if it is not, then it is a rather trivial graph that only has hierarchy.  I.e., there can be no links.
 * @param composite The Ptolemy II model.
 */
public AbstractBasicGraphModel(NamedObj composite){
  super(composite);
  _composite=composite;
  _graphChangeListener=new GraphChangeListener();
  composite.addChangeListener(_graphChangeListener);
}

Fixed version (ground truth):
/** 
 * Create a graph model for the specified Ptolemy II model. Note that the argument need not be a CompositeEntity, although if it is not, then it is a rather trivial graph that only has hierarchy.  I.e., there can be no links.
 * @param composite The Ptolemy II model.
 */
public AbstractBasicGraphModel(NamedObj composite){
  super(composite);
  _composite=composite;
  composite.addChangeListener(this);
}
Program: 74950
Project: 74950
Buggy source:
/** 
 * Notify the listener that a change has been successfully executed. If the originator of this change is not this graph model, then issue a graph event to indicate that the structure of the graph has changed.
 * @param change The change that has been executed.
 */
public void changeExecuted(ChangeRequest change){
  if ((change != null) && (change.getSource() == AbstractBasicGraphModel.this)) {
    return;
  }
  if (_update()) {
    dispatchGraphEvent(new GraphEvent(AbstractBasicGraphModel.this,GraphEvent.STRUCTURE_CHANGED,getRoot()));
  }
}

Fixed version (ground truth):
/** 
 * Notify the listener that a change has been successfully executed. If the originator of this change is not this graph model, then issue a graph event to indicate that the structure of the graph has changed.
 * @param change The change that has been executed.
 */
public void changeExecuted(ChangeRequest change){
  if ((change != null) && (change.getSource() == this)) {
    return;
  }
  if (_update()) {
    dispatchGraphEvent(new GraphEvent(this,GraphEvent.STRUCTURE_CHANGED,getRoot()));
  }
}
Program: 74953
Project: 74953
Buggy source:
/** 
 * Construct a parameter with the given container, name, and container class. The specified class will be used to determine which other instances of PtinyOSTOSSIMPort are shared with this one.
 * @param container The container.
 * @param name The name of the parameter.
 * @param containerClass The class used to determine shared instances.
 * @exception IllegalActionException If the parameter is not of anacceptable class for the container.
 * @exception NameDuplicationException If the name coincides witha parameter already in the container.
 */
public PtinyOSTOSSIMPort(NamedObj container,String name,Class containerClass) throws IllegalActionException, NameDuplicationException {
  super(container,name,containerClass,"String_Node_Str");
  setTypeEquals(BaseType.INT);
  SharedParameter sp=(SharedParameter)this;
}

Fixed version (ground truth):
/** 
 * Construct a parameter with the given container, name, and container class. The specified class will be used to determine which other instances of PtinyOSTOSSIMPort are shared with this one.
 * @param container The container.
 * @param name The name of the parameter.
 * @param containerClass The class used to determine shared instances.
 * @param incrementValue The value with which to incrementsubsequent parameters.
 * @exception IllegalActionException If the parameter is not of anacceptable class for the container.
 * @exception NameDuplicationException If the name coincides witha parameter already in the container.
 */
public PtinyOSTOSSIMPort(NamedObj container,String name,Class containerClass,int incrementValue) throws IllegalActionException, NameDuplicationException {
  super(container,name,containerClass,String.valueOf(_defaultValue));
  setTypeEquals(BaseType.INT);
  _incrementValue=incrementValue;
}
Program: 74955
Project: 74955
Buggy source:
/** 
 * Compute a composite bounding box. The iterator must contain figures, from which the bounding boxes are obtained and joined into a more complex shape. If the iterator is empty, return a very small rectangle.
 */
public static Rectangle2D computeCompositeBounds(Iterator i){
  if (!i.hasNext()) {
    return new Rectangle2D.Double();
  }
  Figure f=(Figure)i.next();
  Rectangle2D b=f.getBounds();
  Rectangle2D bounds=new Rectangle2D.Double(b.getX(),b.getY(),b.getWidth(),b.getHeight());
  while (i.hasNext()) {
    f=(Figure)i.next();
    Rectangle2D.union(bounds,f.getBounds(),bounds);
  }
  return bounds;
}

Fixed version (ground truth):
/** 
 * Compute a composite bounding box. The iterator must contain figures, from which the bounding boxes are obtained and joined into a more complex shape. If the iterator is empty, return a very small rectangle.
 */
public static Rectangle2D computeCompositeBounds(Iterator i){
  if (!i.hasNext()) {
    return new Rectangle2D.Double();
  }
  Figure f=(Figure)i.next();
  while (!f.isVisible()) {
    if (!i.hasNext()) {
      return new Rectangle2D.Double();
    }
    f=(Figure)i.next();
  }
  Rectangle2D b=f.getBounds();
  Rectangle2D bounds=new Rectangle2D.Double(b.getX(),b.getY(),b.getWidth(),b.getHeight());
  while (i.hasNext()) {
    f=(Figure)i.next();
    if (!f.isVisible()) {
      continue;
    }
    Rectangle2D.union(bounds,f.getBounds(),bounds);
  }
  return bounds;
}
Program: 74957
Project: 74957
Buggy source:
/** 
 * Return the timestamp of the next event in the queue. The next iteration time, for example, is used to estimate the run-ahead time, when a continuous time composite actor is embedded in a DE model. If there is no event in the event queue, a positive infinity object is returned.
 * @return The time stamp of the next event in the event queue.
 */
public Time getModelNextIterationTime(){
  Time aFutureTime=Time.POSITIVE_INFINITY;
  if (_eventQueue.size() > 0) {
    aFutureTime=_eventQueue.get().timeStamp();
  }
  Director executiveDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (executiveDirector != null) {
    Time aFutureTimeOfUpperLevel=executiveDirector.getModelNextIterationTime();
    if (aFutureTime.compareTo(aFutureTimeOfUpperLevel) > 0) {
      aFutureTime=aFutureTimeOfUpperLevel;
    }
  }
  return aFutureTime;
}

Fixed version (ground truth):
/** 
 * Return the timestamp of the next event in the queue. The next iteration time, for example, is used to estimate the run-ahead time, when a continuous time composite actor is embedded in a DE model. If there is no event in the event queue, a positive infinity object is returned.
 * @return The time stamp of the next event in the event queue.
 */
public Time getModelNextIterationTime(){
  Time aFutureTime=Time.POSITIVE_INFINITY;
  if (_eventQueue.size() > 0) {
    aFutureTime=_eventQueue.get().timeStamp();
  }
  Object[] events=_eventQueue.toArray();
  for (int i=0; i < events.length; i++) {
    DEEvent event=(DEEvent)events[i];
    Time eventTime=event.timeStamp();
    int eventMicrostep=event.microstep();
    if (eventTime.compareTo(getModelTime()) > 0 || eventMicrostep > _microstep) {
      aFutureTime=eventTime;
      break;
    }
  }
  Director executiveDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (executiveDirector != null) {
    Time aFutureTimeOfUpperLevel=executiveDirector.getModelNextIterationTime();
    if (aFutureTime.compareTo(aFutureTimeOfUpperLevel) > 0) {
      aFutureTime=aFutureTimeOfUpperLevel;
    }
  }
  return aFutureTime;
}
Program: 74962
Project: 74962
Buggy source:
/** 
 * Get the receivers that are ready to form a rendezvous according to the rendezvous semantics. If no rendezvous can be formed starting for the given array of receivers, null is returned.
 * @param receivers The array of receivers to be put to or get from.
 * @param isPut If true, the rendezvous is to put tokens to the receivers; if false, the rendezvous is to get tokens from the receivers.
 * @return A set of receivers that participate in the rendezvous if it canbe formed, or null if no rendezvous can be formed.
 * @see #_commitRendezvous(Set,RendezvousDirector)
 */
protected static Set _receiversReadyToCommit(Receiver[][] receivers,boolean isPut){
  Set ready=new HashSet();
  if (_checkRendezvous(receivers,isPut,new HashSet(),ready,new HashSet(),new HashSet(),false,false)) {
    return ready;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Get the receivers that are ready to form a rendezvous according to the rendezvous semantics. If no rendezvous can be formed starting for the given array of receivers, null is returned.
 * @param receivers The array of receivers to be put to or get from.
 * @param isPut If true, the rendezvous is to put tokens to the receivers; if false, the rendezvous is to get tokens from the receivers.
 * @return A set of receivers that participate in the rendezvous if it canbe formed, or null if no rendezvous can be formed.
 * @see #_commitRendezvous(Set,RendezvousDirector)
 */
protected static Set _receiversReadyToCommit(Receiver[][] receivers,boolean isPut){
  Set ready=new HashSet();
  if (_checkRendezvous(receivers,isPut,new HashSet(),ready,new HashSet(),new HashSet(),false,false,null)) {
    return ready;
  }
 else {
    return null;
  }
}
Program: 74964
Project: 74964
Buggy source:
/** 
 * Get the branch of the two-dimensional array of receivers that has been selected by previous recursive calls of   {@link #_checkRendezvous(Receiver[][],boolean,Set,Set,Set,boolean,boolean)}.
 * @param receivers The two-dimensional array of receivers.
 * @param beingChecked The set of receivers that are being checked by previous recursive calls.
 * @return The index of the selected branch, or -1 if no branch has beenselected yet.
 */
private static int _getSelectedBranch(Receiver[][] receivers,Set beingChecked){
  for (int i=0; i < receivers.length; i++) {
    if (receivers[i] != null) {
      for (int j=0; j < receivers[i].length; j++) {
        Receiver receiver=(Receiver)receivers[i][j];
        if (receiver != null && beingChecked.contains(receiver)) {
          return i;
        }
      }
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * Get the branch of the two-dimensional array of receivers that has been selected by previous recursive calls of   {@link #_checkRendezvous(Receiver[][],boolean,Set,Set,Set,boolean,boolean)}.
 * @param receivers The two-dimensional array of receivers.
 * @param beingChecked The set of receivers that are being checked by previous recursive calls.
 * @param ready The set of receivers that are ready for a rendezvous.
 * @return The index of the selected branch, or -1 if no branch has beenselected yet.
 */
private static int _getSelectedBranch(Receiver[][] receivers,Set beingChecked,Set ready){
  for (int i=0; i < receivers.length; i++) {
    if (receivers[i] == null) {
      continue;
    }
    for (int j=0; j < receivers[i].length; j++) {
      Receiver receiver=(Receiver)receivers[i][j];
      if (receiver == null) {
        continue;
      }
      if (beingChecked.contains(receiver) || ready.contains(receiver)) {
        return i;
      }
    }
  }
  return -1;
}
Program: 74967
Project: 74967
Buggy source:
protected Receiver next(){
  Iterator zeroInDegreeIterator=_zeroInDegree.iterator();
  if (!zeroInDegreeIterator.hasNext()) {
    return null;
  }
  RendezvousReceiver next=(RendezvousReceiver)zeroInDegreeIterator.next();
  zeroInDegreeIterator.remove();
  if (next._symmetricPutReceivers != null) {
    Token token=next._token;
    Receiver[][] putReceivers=next._symmetricPutReceivers;
    if (next._getConditional) {
      for (int i=0; i < putReceivers.length; i++) {
        if (putReceivers[i] != null) {
          for (int j=0; j < putReceivers[i].length; j++) {
            if (putReceivers[i][j] != null) {
              ((RendezvousReceiver)putReceivers[i][j])._token=token;
              _zeroInDegree.add(putReceivers[i][j]);
            }
          }
        }
      }
    }
 else {
    }
  }
  return next;
}

Fixed version (ground truth):
protected Receiver next(){
  Iterator zeroInDegreeIterator=_zeroInDegree.iterator();
  if (!zeroInDegreeIterator.hasNext()) {
    return null;
  }
  RendezvousReceiver next=(RendezvousReceiver)zeroInDegreeIterator.next();
  zeroInDegreeIterator.remove();
  if (next._symmetricPutReceivers != null) {
    Token token=next._token;
    Receiver[][] putReceivers=next._symmetricPutReceivers;
    if (next._getConditional) {
      for (int i=0; i < putReceivers.length; i++) {
        if (putReceivers[i] != null) {
          for (int j=0; j < putReceivers[i].length; j++) {
            if (putReceivers[i][j] != null) {
              if (!_receivers.contains(putReceivers[i][j])) {
                continue;
              }
              RendezvousReceiver castReceiver=(RendezvousReceiver)putReceivers[i][j];
              castReceiver._token=token;
              _zeroInDegree.add(putReceivers[i][j]);
            }
          }
        }
      }
    }
 else {
      throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
    }
  }
  return next;
}
Program: 74968
Project: 74968
Buggy source:
private void _initializeZeroInDegree(Set receivers){
  _zeroInDegree=new HashSet();
  Iterator iterator=receivers.iterator();
  while (iterator.hasNext()) {
    RendezvousReceiver receiver=(RendezvousReceiver)iterator.next();
    if (receiver._symmetricGetReceivers == null) {
      _zeroInDegree.add(receiver);
    }
  }
  if (_zeroInDegree.isEmpty()) {
    throw new InternalErrorException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void _initializeZeroInDegree(){
  _zeroInDegree=new HashSet();
  Iterator iterator=_receivers.iterator();
  while (iterator.hasNext()) {
    RendezvousReceiver receiver=(RendezvousReceiver)iterator.next();
    if (receiver._symmetricGetReceivers == null) {
      _zeroInDegree.add(receiver);
    }
  }
  if (_zeroInDegree.isEmpty()) {
    throw new InternalErrorException("String_Node_Str");
  }
}
Program: 74970
Project: 74970
Buggy source:
protected TopologicalSort(Set receivers){
  _initializeZeroInDegree(receivers);
}

Fixed version (ground truth):
protected TopologicalSort(Set receivers){
  _receivers=receivers;
  _initializeZeroInDegree();
}
Program: 74971
Project: 74971
Buggy source:
/** 
 * Commit the rendezvous formed by the set of receivers that agree to send and receive at the same time.
 * @param receivers The receivers that participate in the rendezvous.
 * @param director The director.
 * @see #_receiversReadyToCommit(Receiver[][],boolean)
 */
private static void _commitRendezvous(Set receivers,RendezvousDirector director){
  Map result=new HashMap();
  TopologicalSort sort=new TopologicalSort(receivers);
  while (sort.hasNext()) {
    RendezvousReceiver castReceiver=(RendezvousReceiver)sort.next();
    result.put(castReceiver,castReceiver._token);
    if (_getData(castReceiver._getWaiting) == null) {
      director.threadUnblocked(castReceiver._getWaiting,null);
      _setData(castReceiver._getWaiting,result);
    }
    if (_getData(castReceiver._putWaiting) == null) {
      director.threadUnblocked(castReceiver._putWaiting,null);
      _setData(castReceiver._putWaiting,result);
    }
  }
  Iterator receiverIterator=receivers.iterator();
  while (receiverIterator.hasNext()) {
    RendezvousReceiver castReceiver=(RendezvousReceiver)receiverIterator.next();
    if ((castReceiver._getReceivers != null) && castReceiver._getConditional) {
      _resetReceiversFlags(castReceiver._getReceivers,true,false);
    }
    if ((castReceiver._putReceivers != null) && castReceiver._putConditional) {
      _resetReceiversFlags(castReceiver._putReceivers,false,true);
    }
    castReceiver._resetFlags(true,true);
  }
}

Fixed version (ground truth):
/** 
 * Commit the rendezvous formed by the set of receivers that agree to send and receive at the same time.
 * @param receivers The receivers that participate in the rendezvous.
 * @param director The director.
 * @see #_receiversReadyToCommit(Receiver[][],boolean)
 */
private static void _commitRendezvous(Set receivers,RendezvousDirector director){
  Map result=new HashMap();
  if (receivers.size() == 2) {
    int x=0;
  }
  TopologicalSort sort=new TopologicalSort(receivers);
  int num=0;
  while (sort.hasNext()) {
    num++;
    RendezvousReceiver castReceiver=(RendezvousReceiver)sort.next();
    result.put(castReceiver,castReceiver._token);
    if (_getData(castReceiver._getWaiting) == null) {
      director.threadUnblocked(castReceiver._getWaiting,null);
      _setData(castReceiver._getWaiting,result);
    }
    if (_getData(castReceiver._putWaiting) == null) {
      director.threadUnblocked(castReceiver._putWaiting,null);
      _setData(castReceiver._putWaiting,result);
    }
  }
  Iterator receiverIterator=receivers.iterator();
  while (receiverIterator.hasNext()) {
    RendezvousReceiver castReceiver=(RendezvousReceiver)receiverIterator.next();
    if ((castReceiver._getReceivers != null) && castReceiver._getConditional) {
      _resetReceiversFlags(castReceiver._getReceivers,true,false);
    }
    if ((castReceiver._putReceivers != null) && castReceiver._putConditional) {
      _resetReceiversFlags(castReceiver._putReceivers,false,true);
    }
    castReceiver._resetFlags(true,true);
  }
}
Program: 74973
Project: 74973
Buggy source:
/** 
 * Get the receivers that are ready to form a rendezvous according to the rendezvous semantics. If no rendezvous can be formed starting for the given array of receivers, null is returned.
 * @param receivers The array of receivers to be put to or get from.
 * @param isPut If true, the rendezvous is to put tokens to thereceivers; if false, the rendezvous is to get tokens from the receivers.
 * @param readyReceivers The set of receivers that are already ready for arendezvous, or null if no receivers are already ready.
 * @return A set of receivers that participate in the rendezvous ifit can be formed, or null if no rendezvous can be formed.
 * @see #_commitRendezvous(Set,RendezvousDirector)
 */
private static Set _receiversReadyToCommit(Receiver[][] receivers,boolean isPut,Set readyReceivers){
  if (readyReceivers == null) {
    readyReceivers=new HashSet();
  }
  int oldReadyReceiversSize=readyReceivers.size();
  Set checkedReceivers=_receiversReadyToCommitRecursive(receivers,isPut,readyReceivers);
  if (checkedReceivers == null) {
    return null;
  }
  readyReceivers.addAll(checkedReceivers);
  if (readyReceivers.size() == oldReadyReceiversSize) {
    return readyReceivers;
  }
  Iterator receiverIterator=checkedReceivers.iterator();
  while (receiverIterator.hasNext()) {
    RendezvousReceiver receiver=(RendezvousReceiver)receiverIterator.next();
    Receiver[][][] symmetricReceivers=new Receiver[][][]{receiver._symmetricGetReceivers,receiver._symmetricPutReceivers};
    for (int i=0; i < 2; i++) {
      if (symmetricReceivers[i] != null) {
        Set newCheckedReceivers=_receiversReadyToCommit(symmetricReceivers[i],i == 1,readyReceivers);
        if (newCheckedReceivers == null) {
          return null;
        }
 else {
          readyReceivers.addAll(newCheckedReceivers);
        }
      }
    }
  }
  return readyReceivers;
}

Fixed version (ground truth):
/** 
 * Get the receivers that are ready to form a rendezvous according to the rendezvous semantics. If no rendezvous can be formed starting for the given array of receivers, null is returned.
 * @param receivers The array of receivers to be put to or get from.
 * @param isPut If true, the rendezvous is to put tokens to thereceivers; if false, the rendezvous is to get tokens from the receivers.
 * @return A set of receivers that participate in the rendezvous ifit can be formed, or null if no rendezvous can be formed.
 * @see #_commitRendezvous(Set,RendezvousDirector)
 */
private static Set _receiversReadyToCommit(Receiver[][] receivers,boolean isPut){
  return _receiversReadyToCommitRecursive(receivers,isPut,null);
}
Program: 74975
Project: 74975
Buggy source:
/** 
 * Return the timestamp of the next event in the queue. The next iteration time, for example, is used to estimate the run-ahead time, when a continuous time composite actor is embedded in a DE model. If there is no event in the event queue, a positive infinity object is returned.
 * @return The time stamp of the next event in the event queue.
 */
public Time getModelNextIterationTime(){
  Time aFutureTime=Time.POSITIVE_INFINITY;
  if (_eventQueue.size() > 0) {
    aFutureTime=_eventQueue.get().timeStamp();
  }
  return aFutureTime;
}

Fixed version (ground truth):
/** 
 * Return the timestamp of the next event in the queue. The next iteration time, for example, is used to estimate the run-ahead time, when a continuous time composite actor is embedded in a DE model. If there is no event in the event queue, a positive infinity object is returned.
 * @return The time stamp of the next event in the event queue.
 */
public Time getModelNextIterationTime(){
  Time aFutureTime=Time.POSITIVE_INFINITY;
  if (_eventQueue.size() > 0) {
    aFutureTime=_eventQueue.get().timeStamp();
  }
  Director executiveDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (executiveDirector != null) {
    Time aFutureTimeOfUpperLevel=executiveDirector.getModelNextIterationTime();
    if (aFutureTime.compareTo(aFutureTimeOfUpperLevel) > 0) {
      aFutureTime=aFutureTimeOfUpperLevel;
    }
  }
  return aFutureTime;
}
Program: 74977
Project: 74977
Buggy source:
/** 
 * Generate preinitialize code (if there is any). This method calls the generatePreinitializeCode() method of the code generator helper associated with the model director
 * @return The preinitialize code of the containing composite actor.
 * @exception IllegalActionException If the helper class for the modeldirector cannot be found, or if an error occurs when the director helper generates preinitialize code.
 */
public String generatePreinitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  ptolemy.actor.Director director=((CompositeActor)getContainer()).getDirector();
  CompositeEntity model=(CompositeEntity)getContainer();
  if (director == null) {
    throw new IllegalActionException(this,"String_Node_Str" + model.getName() + "String_Node_Str");
  }
  TypedCompositeActor compositeActorHelper=(TypedCompositeActor)_getHelper(getContainer());
  code.append(compositeActorHelper.generatePreinitializeCode());
  _modifiedVariables=compositeActorHelper.getModifiedVariables();
  Attribute iterations=director.getAttribute("String_Node_Str");
  if (iterations != null) {
    int iterationCount=((IntToken)((Variable)iterations).getToken()).intValue();
    if (iterationCount > 0) {
      code.append("String_Node_Str");
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate preinitialize code (if there is any). This method calls the generatePreinitializeCode() method of the code generator helper associated with the model director
 * @return The preinitialize code of the containing composite actor.
 * @exception IllegalActionException If the helper class for the modeldirector cannot be found, or if an error occurs when the director helper generates preinitialize code.
 */
public String generatePreinitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  ptolemy.actor.Director director=((CompositeActor)getContainer()).getDirector();
  CompositeEntity model=(CompositeEntity)getContainer();
  if (director == null) {
    throw new IllegalActionException(this,"String_Node_Str" + model.getName() + "String_Node_Str");
  }
  TypedCompositeActor compositeActorHelper=(TypedCompositeActor)_getHelper(getContainer());
  _modifiedVariables=compositeActorHelper.getModifiedVariables();
  code.append(compositeActorHelper.generatePreinitializeCode());
  Attribute iterations=director.getAttribute("String_Node_Str");
  if (iterations != null) {
    int iterationCount=((IntToken)((Variable)iterations).getToken()).intValue();
    if (iterationCount > 0) {
      code.append("String_Node_Str");
    }
  }
  return code.toString();
}
Program: 74980
Project: 74980
Buggy source:
public static void main(String[] args){
  if (args.length < 3) {
    System.err.println("String_Node_Str" + "String_Node_Str");
    return;
  }
  int i=0;
  String inputSuffix=args[i++].trim();
  String toplevelOutputFilename=args[i++].trim();
  String outputFilename=args[i++].trim();
  String rootDir=args[i++].trim();
  try {
    MoMLLib.proc(inputSuffix,outputFilename,toplevelOutputFilename,rootDir,rootDir);
  }
 catch (  Throwable throwable) {
    System.err.println("String_Node_Str" + throwable);
    throwable.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  if (args.length < 3) {
    System.err.println("String_Node_Str" + "String_Node_Str");
    return;
  }
  int i=0;
  String inputSuffix=args[i++].trim();
  String toplevelOutputFilename=args[i++].trim();
  String outputFilename=args[i++].trim();
  String rootDir=args[i++].trim();
  try {
    MoMLLib.proc(inputSuffix,outputFilename,toplevelOutputFilename,true,rootDir,rootDir);
  }
 catch (  Throwable throwable) {
    System.err.println("String_Node_Str" + throwable);
    throwable.printStackTrace();
  }
}
Program: 74981
Project: 74981
Buggy source:
public boolean accept(File dir,String name){
  return name.endsWith(inputSuffix) && !name.equals(indexFilename);
}

Fixed version (ground truth):
public boolean accept(File dir,String name){
  return name.endsWith(inputSuffix) && !name.equals(indexFilename) && !name.equals(indexFilenameTopLevel);
}
Program: 74989
Project: 74989
Buggy source:
public static void main(String[] args) throws IOException {
  if (args.length < 2) {
    System.err.println("String_Node_Str");
    return;
  }
  String inputSuffix=args[0].trim();
  String outputFilename=args[1].trim();
  String rootDir=args[2].trim();
  try {
    MoMLLib.proc(inputSuffix,outputFilename,rootDir,rootDir);
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws IOException {
  if (args.length < 2) {
    System.err.println("String_Node_Str" + "String_Node_Str");
    return;
  }
  String inputSuffix=args[0].trim();
  String outputFilename=args[1].trim();
  String rootDir=args[2].trim();
  try {
    MoMLLib.proc(inputSuffix,outputFilename,rootDir,rootDir);
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}
Program: 74990
Project: 74990
Buggy source:
private void _setupPreviewPage(){
  int pageIndex=1;
  _preview=new PtolemyEditor();
  IFile previewFile=_getPreviewFile();
  if (previewFile != null) {
    try {
      _preview.init(_editor.getEditorSite(),new IEditorInput(){
        public boolean exists(){
          return true;
        }
        public ImageDescriptor getImageDescriptor(){
          return null;
        }
        public String getName(){
          return "String_Node_Str";
        }
        public IPersistableElement getPersistable(){
          return null;
        }
        public String getToolTipText(){
          return "String_Node_Str";
        }
        public Object getAdapter(        Class adapter){
          return null;
        }
      }
);
    }
 catch (    Exception e) {
      OutputConsole.outputError(e.getMessage());
    }
  }
}

Fixed version (ground truth):
private void _setupPreviewPage(){
  int pageIndex=1;
  _preview=new PtolemyEditor();
  IFile previewFile=_getPreviewFile();
  if (previewFile != null) {
    try {
      _preview.init(_editor.getEditorSite(),getEditorInput());
    }
 catch (    Exception e) {
      OutputConsole.outputError(e.getMessage());
    }
  }
}
Program: 74993
Project: 74993
Buggy source:
/** 
 * Construct an actor in the specified container with the specified name.  The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
 * @param container The container.
 * @param name The name.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public Barrier(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  _branchController=new MultiwayBranchController(this);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setMultiport(true);
  Parameter groupReceivers=new Parameter(input,"String_Node_Str");
  groupReceivers.setPersistent(false);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setMultiport(true);
  groupReceivers=new Parameter(output,"String_Node_Str");
  groupReceivers.setPersistent(false);
}

Fixed version (ground truth):
/** 
 * Construct an actor in the specified container with the specified name.  The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.
 * @param container The container.
 * @param name The name.
 * @exception IllegalActionException If the actor cannot be containedby the proposed container.
 * @exception NameDuplicationException If the name coincides withan actor already in the container.
 */
public Barrier(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  _branchController=new MultiwayBranchController(this);
  input=new TypedIOPort(this,"String_Node_Str",true,false);
  input.setMultiport(true);
  output=new TypedIOPort(this,"String_Node_Str",false,true);
  output.setMultiport(true);
}