nus-yam/ex-repair huggingface dataset:
Program: 75683
Project: 75683
Buggy source:
/** 
 * Fire on a rise in trigger, don't on a fall. Fire on equal consecutive values Perform initialization for clock cycle
 */
public boolean prefire() throws IllegalActionException {
  double currentTime=getDirector().getCurrentTime();
  System.out.println("String_Node_Str" + currentTime);
  if (trigger.hasToken(0)) {
    System.out.println("String_Node_Str");
    _trigger=((BooleanToken)trigger.get(0)).booleanValue();
  }
  System.out.println("String_Node_Str" + _trigger);
  if (!_oldTrigger && _trigger) {
    _tentativeCycleStartTime=currentTime;
    _tentativePhase=0;
    _tentativeCurrentValue=_getValue(_phase);
    System.out.println("String_Node_Str");
    return super.prefire();
  }
 else   if (_oldTrigger && !_trigger) {
    _oldTrigger=_trigger;
    System.out.println("String_Node_Str");
    return false;
  }
 else {
    System.out.println("String_Node_Str");
    return super.prefire();
  }
}

Fixed version (ground truth):
public boolean prefire() throws IllegalActionException {
  return super.prefire();
}
Program: 75685
Project: 75685
Buggy source:
/** 
 * Initialize trigger and oldtriggger.
 */
public void initialize() throws IllegalActionException {
  _trigger=false;
  _oldTrigger=false;
  super.initialize();
}

Fixed version (ground truth):
/** 
 * Initialize trigger
 */
public void initialize() throws IllegalActionException {
  _trigger=false;
  super.initialize();
}
Program: 75687
Project: 75687
Buggy source:
/** 
 * Generate Giotto code for the _container model.
 * @return The Giotto code.
 */
public String generateCode() throws IllegalActionException {
  try {
    generatedCode="String_Node_Str";
    _modeCode="String_Node_Str";
    if (!_initialize()) {
      return "String_Node_Str";
    }
    String containerName=_container.getName();
    generatedCode+=_compositeAgentCode(_container) + _modeCode;
  }
 catch (  IllegalActionException ex) {
    System.out.println(ex.getMessage());
    throw new IllegalActionException(ex.getMessage());
  }
  return generatedCode;
}

Fixed version (ground truth):
/** 
 * Generate Charon code for the _container model.
 * @return The Charon code.
 */
public String generateCode() throws IllegalActionException {
  try {
    generatedCode="String_Node_Str";
    _modeCode="String_Node_Str";
    if (!_initialize()) {
      return "String_Node_Str";
    }
    String containerName=_container.getName();
    generatedCode+=_compositeAgentCode(_container) + _modeCode;
  }
 catch (  IllegalActionException ex) {
    System.out.println(ex.getMessage());
    throw new IllegalActionException(ex.getMessage());
  }
  return generatedCode;
}
Program: 75691
Project: 75691
Buggy source:
/** 
 * Request restoration of the user settable attribute values to what they were when this object was created.  The actual restoration occurs later, in the UI thread, in order to allow all pending changes to the attribute values to be processed first.
 */
public void restore(){
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      Iterator entries=_originalValues.entrySet().iterator();
      while (entries.hasNext()) {
        Map.Entry entry=(Map.Entry)entries.next();
        Settable parameter=(Settable)_object.getAttribute((String)entry.getKey());
        try {
          parameter.setExpression((String)entry.getValue());
          if (parameter instanceof Variable) {
            ((Variable)parameter).getToken();
          }
        }
 catch (        IllegalActionException ex) {
        }
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Request restoration of the user settable attribute values to what they were when this object was created.  The actual restoration occurs later, in the UI thread, in order to allow all pending changes to the attribute values to be processed first.
 */
public void restore(){
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      MoMLChangeRequest request=new MoMLChangeRequest(this,_parent,_restoreMoML,null);
      _object.requestChange(request);
    }
  }
);
}
Program: 75692
Project: 75692
Buggy source:
public void run(){
  Iterator entries=_originalValues.entrySet().iterator();
  while (entries.hasNext()) {
    Map.Entry entry=(Map.Entry)entries.next();
    Settable parameter=(Settable)_object.getAttribute((String)entry.getKey());
    try {
      parameter.setExpression((String)entry.getValue());
      if (parameter instanceof Variable) {
        ((Variable)parameter).getToken();
      }
    }
 catch (    IllegalActionException ex) {
    }
  }
}

Fixed version (ground truth):
public void run(){
  MoMLChangeRequest request=new MoMLChangeRequest(this,_parent,_restoreMoML,null);
  _object.requestChange(request);
}
Program: 75694
Project: 75694
Buggy source:
/** 
 * Return false if the system has finished executing, either by reaching the iteration limit, or by having an actor in the model return false in postfire.
 * @return True if the execution is not finished.
 * @exception IllegalActionException If the iterations parameter doesnot have a valid token.
 */
public boolean postfire() throws IllegalActionException {
  int numberOfIterations=((IntToken)(iterations.getToken())).intValue();
  if (_debugging) {
    _debug("String_Node_Str" + _iterationCount);
  }
  _expectedNextIterationTime+=_unitTimeIncrement;
  if (_debugging) {
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  if ((numberOfIterations > 0) && (_iterationCount > numberOfIterations)) {
    _iterationCount=0;
    _transferOutputsOnly=false;
    if (_isEmbedded()) {
      return true;
    }
 else {
      return false;
    }
  }
 else {
    if ((numberOfIterations > 0) && (_iterationCount == numberOfIterations)) {
      _transferOutputsOnly=true;
    }
    if (_isEmbedded()) {
      _requestFiring();
    }
 else {
      setCurrentTime(_expectedNextIterationTime);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return false if the system has finished executing, either by reaching the iteration limit, or by having an actor in the model return false in postfire.
 * @return True if the execution is not finished.
 * @exception IllegalActionException If the iterations parameter doesnot have a valid token.
 */
public boolean postfire() throws IllegalActionException {
  _unitIndex++;
  if (_unitIndex >= _schedule.size()) {
    _unitIndex=0;
    if (_debugging) {
      _debug("String_Node_Str" + _iterationCount);
    }
    _iterationCount++;
  }
  int numberOfIterations=((IntToken)(iterations.getToken())).intValue();
  _expectedNextIterationTime+=_unitTimeIncrement;
  if (_debugging) {
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  if ((numberOfIterations > 0) && (_iterationCount >= numberOfIterations) && (_transferOutputsOnly == true)) {
    _iterationCount=0;
    _transferOutputsOnly=false;
    if (_isEmbedded()) {
      return true;
    }
 else {
      return false;
    }
  }
 else {
    if ((numberOfIterations > 0) && (_iterationCount == numberOfIterations)) {
      _transferOutputsOnly=true;
    }
    if (_isEmbedded()) {
      _requestFiring();
    }
 else {
      setCurrentTime(_expectedNextIterationTime);
    }
  }
  return true;
}
Program: 75695
Project: 75695
Buggy source:
/** 
 * Return true if the current time of the outside domain is greater than or equal to the current time.
 * @return True if the director is ready to run for one iteration.
 */
public boolean prefire() throws IllegalActionException {
  if (_isEmbedded()) {
    setCurrentTime((((CompositeActor)getContainer()).getExecutiveDirector()).getCurrentTime());
  }
  _expectedNextIterationTime=getCurrentTime();
  if (_debugging) {
    _debug("String_Node_Str");
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  Director upperDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (upperDirector instanceof CTDirector) {
    if (Math.abs(getCurrentTime() - _expectedNextIterationTime) < ((CTDirector)upperDirector).getTimeResolution()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return true;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return false;
  }
 else {
    if (getCurrentTime() < _expectedNextIterationTime) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return false;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Return true if the current time of the outside domain is greater than or equal to the current time.
 * @return True if the director is ready to run for one iteration.
 */
public boolean prefire() throws IllegalActionException {
  if (_isEmbedded()) {
    setCurrentTime((((CompositeActor)getContainer()).getExecutiveDirector()).getCurrentTime());
  }
  if (_debugging) {
    _debug("String_Node_Str");
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  Director upperDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (upperDirector instanceof CTDirector) {
    if (Math.abs(getCurrentTime() - _expectedNextIterationTime) < ((CTDirector)upperDirector).getTimeResolution()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return true;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return false;
  }
 else {
    if (getCurrentTime() < _expectedNextIterationTime) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      _expectedNextIterationTime=getCurrentTime();
      return false;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return true;
  }
}
Program: 75697
Project: 75697
Buggy source:
/** 
 * Initialize the actors associated with this director. The order in which the actors are initialized is arbitrary.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  _iterationCount=0;
  _unitIndex=0;
  _expectedNextIterationTime=0.0;
  Iterator receivers=_receivers.iterator();
  while (receivers.hasNext()) {
    GiottoReceiver receiver=(GiottoReceiver)receivers.next();
    receiver.reset();
  }
  super.initialize();
  CompositeActor compositeActor=(CompositeActor)(getContainer());
  List actorList=compositeActor.deepEntityList();
  ListIterator actors=actorList.listIterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    List outputPortList=actor.outputPortList();
    Iterator outputPorts=outputPortList.iterator();
    while (outputPorts.hasNext()) {
      IOPort port=(IOPort)outputPorts.next();
      Parameter initialValueParameter=(Parameter)((NamedObj)port).getAttribute("String_Node_Str");
      if (initialValueParameter != null) {
        port.broadcast(initialValueParameter.getToken());
      }
    }
  }
  GiottoScheduler scheduler=(GiottoScheduler)getScheduler();
  _schedule=scheduler.getSchedule();
  _unitTimeIncrement=scheduler.getMinTimeStep(_periodValue);
  _realStartTime=System.currentTimeMillis();
}

Fixed version (ground truth):
/** 
 * Initialize the actors associated with this director. The order in which the actors are initialized is arbitrary.
 * @exception IllegalActionException If the initialize() method ofone of the associated actors throws it.
 */
public void initialize() throws IllegalActionException {
  _iterationCount=0;
  _unitIndex=0;
  _expectedNextIterationTime=0.0;
  Iterator receivers=_receivers.iterator();
  while (receivers.hasNext()) {
    GiottoReceiver receiver=(GiottoReceiver)receivers.next();
    receiver.reset();
  }
  super.initialize();
  CompositeActor compositeActor=(CompositeActor)(getContainer());
  List actorList=compositeActor.deepEntityList();
  ListIterator actors=actorList.listIterator();
  while (actors.hasNext()) {
    Actor actor=(Actor)actors.next();
    List outputPortList=actor.outputPortList();
    Iterator outputPorts=outputPortList.iterator();
    while (outputPorts.hasNext()) {
      IOPort port=(IOPort)outputPorts.next();
      Parameter initialValueParameter=(Parameter)((NamedObj)port).getAttribute("String_Node_Str");
      if (initialValueParameter != null) {
        port.broadcast(initialValueParameter.getToken());
        Receiver[][] channelArray=port.getRemoteReceivers();
        for (int i=0; i < channelArray.length; i++) {
          Receiver[] receiverArray=channelArray[i];
          for (int j=0; j < receiverArray.length; j++) {
            GiottoReceiver receiver=(GiottoReceiver)receiverArray[j];
            receiver.update();
          }
        }
      }
    }
  }
  GiottoScheduler scheduler=(GiottoScheduler)getScheduler();
  _schedule=scheduler.getSchedule();
  _unitTimeIncrement=scheduler._getMinTimeStep(_periodValue);
  _realStartTime=System.currentTimeMillis();
}
Program: 75698
Project: 75698
Buggy source:
/** 
 * Compare two actors based on their <I>frequency</I> parameter. The frequency of an actor that does not have a <I>frequency</I> parameter is DEFAULT_GIOTTO_FREQUENCY.
 * @param actor1 The first actor to be compared.
 * @param actor2 The second actor to be compared.
 * @return -1 if the frequency of the first actor is strictly lessthan that of the second actor, 0 if the frequencies are equal, 1 otherwise.
 * @exception ClassCastException If an argument is null or not aninstance of Actor.
 */
public int compare(Object actor1,Object actor2){
  if (actor1 != null && actor1 instanceof Actor && actor2 != null && actor2 instanceof Actor) {
    if (getFrequency((Actor)actor1) < getFrequency((Actor)actor2))     return -1;
 else     if (getFrequency((Actor)actor1) == getFrequency((Actor)actor2))     return 0;
 else     return 1;
  }
 else   throw new ClassCastException();
}

Fixed version (ground truth):
/** 
 * Compare two actors based on their <I>frequency</I> parameter. The frequency of an actor that does not have a <I>frequency</I> parameter is _DEFAULT_GIOTTO_FREQUENCY.
 * @param actor1 The first actor to be compared.
 * @param actor2 The second actor to be compared.
 * @return -1 if the frequency of the first actor is strictly lessthan that of the second actor, 0 if the frequencies are equal, 1 otherwise.
 * @exception ClassCastException If an argument is null or not aninstance of Actor.
 */
public int compare(Object actor1,Object actor2){
  if (actor1 != null && actor1 instanceof Actor && actor2 != null && actor2 instanceof Actor) {
    if (getFrequency((Actor)actor1) < getFrequency((Actor)actor2))     return -1;
 else     if (getFrequency((Actor)actor1) == getFrequency((Actor)actor2))     return 0;
 else     return 1;
  }
 else   throw new ClassCastException();
}
Program: 75699
Project: 75699
Buggy source:
/** 
 * Return the frequency of the given actor. If the actor has a <I>frequency</I> parameter with a valid integer value, return that value. For actors without a <I>frequency</I> parameter, their frequency is DEFAULT_GIOTTO_FREQUENCY.
 * @param actor An actor.
 * @return The frequency of the actor.
 */
public static int getFrequency(Actor actor){
  try {
    Parameter parameter=(Parameter)((NamedObj)actor).getAttribute("String_Node_Str");
    if (parameter != null) {
      IntToken intToken=(IntToken)parameter.getToken();
      return intToken.intValue();
    }
 else     return DEFAULT_GIOTTO_FREQUENCY;
  }
 catch (  ClassCastException ex) {
    return DEFAULT_GIOTTO_FREQUENCY;
  }
catch (  IllegalActionException ex) {
    return DEFAULT_GIOTTO_FREQUENCY;
  }
}

Fixed version (ground truth):
/** 
 * Return the frequency of the given actor. If the actor has a <I>frequency</I> parameter with a valid integer value, return that value. For actors without a <I>frequency</I> parameter, their frequency is _DEFAULT_GIOTTO_FREQUENCY.
 * @param actor An actor.
 * @return The frequency of the actor.
 */
public static int getFrequency(Actor actor){
  try {
    Parameter parameter=(Parameter)((NamedObj)actor).getAttribute("String_Node_Str");
    if (parameter != null) {
      IntToken intToken=(IntToken)parameter.getToken();
      return intToken.intValue();
    }
 else     return _DEFAULT_GIOTTO_FREQUENCY;
  }
 catch (  ClassCastException ex) {
    return _DEFAULT_GIOTTO_FREQUENCY;
  }
catch (  IllegalActionException ex) {
    return _DEFAULT_GIOTTO_FREQUENCY;
  }
}
Program: 75703
Project: 75703
Buggy source:
/** 
 * Return false if the system has finished executing, either by reaching the iteration limit, or by having an actor in the model return false in postfire.
 * @return True if the execution is not finished.
 * @exception IllegalActionException If the iterations parameter doesnot have a valid token.
 */
public boolean postfire() throws IllegalActionException {
  int numberOfIterations=((IntToken)(iterations.getToken())).intValue();
  if (_debugging) {
    _debug("String_Node_Str" + _iterationCount);
  }
  _expectedNextIterationTime+=_unitTimeIncrement;
  if (_debugging) {
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  if ((numberOfIterations > 0) && (_iterationCount >= numberOfIterations)) {
    _iterationCount=0;
    return false;
  }
 else {
    if (_isEmbedded()) {
      _requestFiring();
    }
 else {
      setCurrentTime(_expectedNextIterationTime);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Return false if the system has finished executing, either by reaching the iteration limit, or by having an actor in the model return false in postfire.
 * @return True if the execution is not finished.
 * @exception IllegalActionException If the iterations parameter doesnot have a valid token.
 */
public boolean postfire() throws IllegalActionException {
  int numberOfIterations=((IntToken)(iterations.getToken())).intValue();
  if (_debugging) {
    _debug("String_Node_Str" + _iterationCount);
  }
  _expectedNextIterationTime+=_unitTimeIncrement;
  if (_debugging) {
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  if ((numberOfIterations > 0) && (_iterationCount >= numberOfIterations)) {
    _iterationCount=0;
    if (_isEmbedded()) {
      return true;
    }
 else {
      return false;
    }
  }
 else {
    if (_isEmbedded()) {
      _requestFiring();
    }
 else {
      setCurrentTime(_expectedNextIterationTime);
    }
  }
  return true;
}
Program: 75704
Project: 75704
Buggy source:
/** 
 * Return true if the current time of the outside domain is greater than or equal to the current time.
 * @return True if the director is ready to run for one iteration.
 */
public boolean prefire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  if (_isEmbedded()) {
    setCurrentTime((((CompositeActor)getContainer()).getExecutiveDirector()).getCurrentTime());
  }
  Director upperDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (upperDirector instanceof CTDirector) {
    if (Math.abs(getCurrentTime() - _expectedNextIterationTime) < ((CTDirector)upperDirector).getTimeResolution()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return true;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return false;
  }
 else {
    if (getCurrentTime() < _expectedNextIterationTime) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return false;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Return true if the current time of the outside domain is greater than or equal to the current time.
 * @return True if the director is ready to run for one iteration.
 */
public boolean prefire() throws IllegalActionException {
  if (_isEmbedded()) {
    setCurrentTime((((CompositeActor)getContainer()).getExecutiveDirector()).getCurrentTime());
  }
  _expectedNextIterationTime=getCurrentTime();
  if (_debugging) {
    _debug("String_Node_Str");
    _debug("String_Node_Str" + _expectedNextIterationTime);
  }
  Director upperDirector=((CompositeActor)getContainer()).getExecutiveDirector();
  if (upperDirector instanceof CTDirector) {
    if (Math.abs(getCurrentTime() - _expectedNextIterationTime) < ((CTDirector)upperDirector).getTimeResolution()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return true;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return false;
  }
 else {
    if (getCurrentTime() < _expectedNextIterationTime) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      return false;
    }
    if (_debugging) {
      _debug("String_Node_Str");
    }
    return true;
  }
}
Program: 75710
Project: 75710
Buggy source:
/** 
 * Consume the input token and the trigger token. The trigger token will be used for finding the zero crossing in the isThisStepAccurate() method to control the step size. The input token will be used in emitCurrentEvent() if the trigger is zero (within the given error tolerance). Notice that this method does not produce any output.
 * @exception IllegalActionException If no token is available.
 */
public void fire() throws IllegalActionException {
  CTDirector director=(CTDirector)getDirector();
  if (director.isDiscretePhase() && hasCurrentEvent()) {
    if (_debugging)     _debug(getFullName() + "String_Node_Str" + _inputToken.toString());
    if (_inputToken != null) {
      output.send(0,_inputToken);
    }
 else {
      output.send(0,defaultEventValue.getToken());
    }
    _eventNow=false;
  }
 else {
    _thisTrigger=((DoubleToken)trigger.get(0)).doubleValue();
    if (_debugging)     _debug(getFullName() + "String_Node_Str" + _thisTrigger);
    if ((input.getWidth() != 0) && input.hasToken(0)) {
      _inputToken=input.get(0);
    }
 else {
      _inputToken=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * Consume the input token and the trigger token. The trigger token will be used for finding the zero crossing in the isThisStepAccurate() method to control the step size. The input token will be used in emitCurrentEvent() if the trigger is zero (within the given error tolerance). Notice that this method does not produce any output.
 * @exception IllegalActionException If no token is available.
 */
public void fire() throws IllegalActionException {
  CTDirector director=(CTDirector)getDirector();
  if (director.isDiscretePhase()) {
    if (hasCurrentEvent()) {
      if (_debugging)       _debug(getFullName() + "String_Node_Str" + _inputToken.toString());
      if (_inputToken != null) {
        output.send(0,_inputToken);
      }
 else {
        output.send(0,defaultEventValue.getToken());
      }
      _eventNow=false;
    }
  }
 else {
    _thisTrigger=((DoubleToken)trigger.get(0)).doubleValue();
    if (_debugging)     _debug(getFullName() + "String_Node_Str" + _thisTrigger);
    if ((input.getWidth() != 0) && input.hasToken(0)) {
      _inputToken=input.get(0);
    }
 else {
      _inputToken=null;
    }
  }
}
Program: 75712
Project: 75712
Buggy source:
/** 
 * Generate Giotto code for the _container model.
 * @return The Giotto code.
 */
public String generateCode() throws IllegalActionException {
  try {
    generatedCode="String_Node_Str";
    _initialize();
    _currentDepth=depthInHierarchy();
    String containerName=_container.getName();
    generatedCode+=_sensorCode();
    generatedCode+=_actuatorCode();
    generatedCode+=_outputCode();
    generatedCode+=_tasksCode();
    generatedCode+=_driversCode();
    generatedCode+="String_Node_Str" + containerName + "String_Node_Str"+ _endLine;
    if (_modeSwitchController != null) {
    }
 else {
      generatedCode+=_modeCode(_container);
    }
    generatedCode+="String_Node_Str" + _endLine;
  }
 catch (  IllegalActionException ex) {
    System.out.println(ex.getMessage());
    throw new IllegalActionException(ex.getMessage());
  }
  return generatedCode;
}

Fixed version (ground truth):
/** 
 * Generate Giotto code for the _container model.
 * @return The Giotto code.
 */
public String generateCode() throws IllegalActionException {
  try {
    generatedCode="String_Node_Str";
    if (!_initialize()) {
      return "String_Node_Str";
    }
    _currentDepth=depthInHierarchy();
    String containerName=_container.getName();
    generatedCode+=_sensorCode();
    generatedCode+=_actuatorCode();
    generatedCode+=_outputCode();
    generatedCode+=_tasksCode();
    generatedCode+=_driversCode();
    generatedCode+="String_Node_Str" + containerName + "String_Node_Str"+ _endLine;
    generatedCode+=_modeCode();
    generatedCode+="String_Node_Str" + _endLine;
  }
 catch (  IllegalActionException ex) {
    System.out.println(ex.getMessage());
    throw new IllegalActionException(ex.getMessage());
  }
  return generatedCode;
}
Program: 75713
Project: 75713
Buggy source:
/** 
 * Topology analysis and initialization.
 */
private void _initialize() throws IllegalActionException {
  _commActors=new LinkedList();
  _modeList=new LinkedList();
  _container1=null;
  _modeSwitchController=null;
  Iterator actors=_container.deepEntityList().iterator();
  while (actors.hasNext()) {
    TypedActor actor=(TypedActor)actors.next();
    _commActors.addLast(actor);
  }
}

Fixed version (ground truth):
/** 
 * Topology analysis and initialization.
 * @ return Ture if in giotto domain, False if in other domains.
 */
private boolean _initialize() throws IllegalActionException {
  _commActors=new LinkedList();
  _modeList=new LinkedList();
  _container=(TypedCompositeActor)getContainer();
  Director director=((CompositeActor)_container).getDirector();
  if (!(director instanceof GiottoDirector))   return false;
  _modeSwitchController=null;
  Iterator actors=_container.deepEntityList().iterator();
  while (actors.hasNext()) {
    TypedActor actor=(TypedActor)actors.next();
    _commActors.addLast(actor);
  }
  return true;
}
Program: 75714
Project: 75714
Buggy source:
/** 
 * Construct a factory with the specified _container and name.
 * @param _container The _container.
 * @param name The name of the factory.
 * @exception IllegalActionException If the factory is not of anacceptable attribute for the _container.
 * @exception NameDuplicationException If the name coincides withan attribute already in the _container.
 */
public GiottoCodeGenerator(NamedObj _container,String name) throws IllegalActionException, NameDuplicationException {
  super(_container,name);
  _attachText("String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  new SingletonAttribute(this,"String_Node_Str");
  new GiottoEditorFactory(this,"String_Node_Str");
  this._container=(TypedCompositeActor)_container;
}

Fixed version (ground truth):
/** 
 * Construct a factory with the specified _container and name.
 * @param _container The _container.
 * @param name The name of the factory.
 * @exception IllegalActionException If the factory is not of anacceptable attribute for the _container.
 * @exception NameDuplicationException If the name coincides withan attribute already in the _container.
 */
public GiottoCodeGenerator(NamedObj _container,String name) throws IllegalActionException, NameDuplicationException {
  super(_container,name);
  _attachText("String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  new SingletonAttribute(this,"String_Node_Str");
  new GiottoEditorFactory(this,"String_Node_Str");
}
Program: 75715
Project: 75715
Buggy source:
/** 
 * Imeplementations of this method should return true if there is an event at the current time.
 * @return True if there is an event to emit now.
 */
public boolean hasCurrentEvent();

Fixed version (ground truth):
/** 
 * Implementations of this method should return true if there is an event at the current time.
 * @return True if there is an event to emit now.
 */
public boolean hasCurrentEvent();
Program: 75716
Project: 75716
Buggy source:
/** 
 * Override the base class and add the element to the Schedule. The reason of overriding this method is to use a more effiecient data structure to store the schedule.
 * @param element The scheduling element.
 */
public void add(ScheduleElement element){
  element.setParent(this);
  _incrementVersion();
  _schedule.add(element);
}

Fixed version (ground truth):
/** 
 * Override the base class and add the element to the Schedule. The reason of overriding this method is to use a more efficient data structure to store the schedule.
 * @param element The scheduling element.
 */
public void add(ScheduleElement element){
  element.setParent(this);
  _incrementVersion();
  _schedule.add(element);
}
Program: 75717
Project: 75717
Buggy source:
public Figure render(Object n){
  Location location=(Location)n;
  NamedObj object=(NamedObj)location.getContainer();
  Figure result=null;
  try {
    List iconList=object.attributeList(EditorIcon.class);
    if (iconList.size() == 0) {
      EditorIcon icon=new XMLIcon(object,"String_Node_Str");
      result=icon.createFigure();
    }
 else     if (iconList.size() == 1) {
      EditorIcon icon=(EditorIcon)iconList.iterator().next();
      result=icon.createFigure();
    }
 else {
      Iterator icons=iconList.iterator();
      result=new CompositeFigure();
      while (icons.hasNext()) {
        EditorIcon icon=(EditorIcon)icons.next();
        ((CompositeFigure)result).add(icon.createFigure());
      }
    }
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(null,ex,"String_Node_Str" + "String_Node_Str" + object + "String_Node_Str"+ "String_Node_Str");
  }
  result.setToolTipText(object.getClass().getName());
  return result;
}

Fixed version (ground truth):
public Figure render(Object n){
  Location location=(Location)n;
  NamedObj object=(NamedObj)location.getContainer();
  Figure result=null;
  try {
    if (USE_CLASSFACTORYATTRIBUTE) {
      List classFactoryList=object.attributeList(VergilClassFactoryAttribute.class);
      Iterator classFactories=classFactoryList.iterator();
      result=new CompositeFigure();
      while (classFactories.hasNext()) {
        VergilClassFactoryAttribute classFactory=(VergilClassFactoryAttribute)classFactories.next();
        System.out.println("String_Node_Str" + "String_Node_Str" + classFactory);
        classFactory.instantiateWithDefaultContainerAndName();
      }
    }
    List iconList=object.attributeList(EditorIcon.class);
    if (iconList.size() == 0) {
      EditorIcon icon=new XMLIcon(object,"String_Node_Str");
      result=icon.createFigure();
    }
 else     if (iconList.size() == 1) {
      EditorIcon icon=(EditorIcon)iconList.iterator().next();
      result=icon.createFigure();
    }
 else {
      Iterator icons=iconList.iterator();
      result=new CompositeFigure();
      while (icons.hasNext()) {
        EditorIcon icon=(EditorIcon)icons.next();
        ((CompositeFigure)result).add(icon.createFigure());
      }
    }
  }
 catch (  KernelException ex) {
    throw new InternalErrorException(null,ex,"String_Node_Str" + "String_Node_Str" + object + "String_Node_Str"+ "String_Node_Str");
  }
  result.setToolTipText(object.getClass().getName());
  return result;
}
Program: 75718
Project: 75718
Buggy source:
/** 
 * Return a new node controller.  This base class returns an instance of IconController.  Derived classes can return some other class to customize the context menu.
 * @param controller The associated graph controller.
 * @return A new node controller.
 */
public NamedObjController create(GraphController controller){
  return new IconController(controller);
}

Fixed version (ground truth):
/** 
 * Return a new node controller.  This base class returns an instance of IconController.  Derived classes can return some other class to customize the context menu.
 * @param controller The associated graph controller.
 * @return A new node controller.
 */
public NamedObjController create(GraphController controller) throws IllegalActionException {
  if (!IconController.USE_CLASSFACTORYATTRIBUTE) {
    return new IconController(controller);
  }
  System.out.println("String_Node_Str" + controller + "String_Node_Str");
  Object[] args=new Object[1];
  args[0]=controller;
  return (NamedObjController)instantiate(args);
}
Program: 75719
Project: 75719
Buggy source:
/** 
 * Construct an attribute with the given name contained by the specified container. The container argument must not be null, or a NullPointerException will be thrown.  This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. The object is added to the directory of the workspace if the container is null. Increment the version of the workspace.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container, or if the name contains a period.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public VergilClassFactoryAttribute(NamedObj container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
}

Fixed version (ground truth):
/** 
 * Construct an attribute with the given name contained by the specified container. The container argument must not be null, or a NullPointerException will be thrown.  This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. The object is added to the directory of the workspace if the container is null. Increment the version of the workspace.
 * @param container The container.
 * @param name The name of this attribute.
 * @exception IllegalActionException If the attribute is not of anacceptable class for the container, or if the name contains a period.
 * @exception NameDuplicationException If the name coincides withan attribute already in the container.
 */
public VergilClassFactoryAttribute(NamedObj container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  System.out.println("String_Node_Str" + container + "String_Node_Str"+ name+ "String_Node_Str");
}
Program: 75720
Project: 75720
Buggy source:
/** 
 * Initialize the execution.
 * @exception IllegalActionException If thrown by the super class.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _first=true;
  _eventNow=false;
  if (_debugging)   _debug(getFullName() + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Initialize the execution.
 * @exception IllegalActionException If thrown by the super class.
 */
public void initialize() throws IllegalActionException {
  super.initialize();
  _first=true;
  _eventMissed=false;
  _enabled=false;
  _eventNow=false;
  if (_debugging)   _debug(getFullName() + "String_Node_Str");
}
Program: 75721
Project: 75721
Buggy source:
/** 
 * If the argument is the <i>reflectionCoefficients</i> parameter, then reallocate the arrays to use.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the base class throws it.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == reflectionCoefficients) {
    ArrayToken value=(ArrayToken)reflectionCoefficients.getToken();
    int valueLength=value.length();
    if (valueLength != _backward.length - 1) {
      _backward=new double[valueLength + 1];
      _forward=new double[valueLength + 1];
      _reflectionCoefs=new double[valueLength];
    }
    for (int i=0; i < valueLength; i++) {
      _reflectionCoefs[i]=((DoubleToken)value.getElement(i)).doubleValue();
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
/** 
 * If the argument is the <i>reflectionCoefficients</i> parameter, then reallocate the arrays to use.
 * @param attribute The attribute that changed.
 * @exception IllegalActionException If the base class throws it.
 */
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == reflectionCoefficients) {
    ArrayToken value=(ArrayToken)reflectionCoefficients.getToken();
    int valueLength=value.length();
    if (_backward == null || valueLength != _backward.length - 1) {
      _backward=new double[valueLength + 1];
      _backwardCache=new double[valueLength + 1];
      _forward=new double[valueLength + 1];
      _forwardCache=new double[valueLength + 1];
      _reflectionCoefs=new double[valueLength];
    }
    for (int i=0; i < valueLength; i++) {
      _reflectionCoefs[i]=((DoubleToken)value.getElement(i)).doubleValue();
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 75722
Project: 75722
Buggy source:
/** 
 * Consume one input token, if there is one, and produce one output token.  If there is no input, the produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    DoubleToken in=(DoubleToken)input.get(0);
    double k;
    int M=_backward.length - 1;
    _forward[0]=in.doubleValue();
    for (int i=1; i <= M; i++) {
      k=_reflectionCoefs[M - i];
      _forward[i]=k * _backward[i] + _forward[i - 1];
    }
    output.broadcast(new DoubleToken(_forward[M]));
    for (int i=1; i < M; i++) {
      k=-_reflectionCoefs[M - 1 - i];
      _backward[i]=_backward[i + 1] + k * _forward[i + 1];
    }
    _backward[M]=_forward[M];
  }
}

Fixed version (ground truth):
/** 
 * Consume one input token, if there is one, and produce one output token.  If there is no input, then produce no output.
 * @exception IllegalActionException If there is no director.
 */
public void fire() throws IllegalActionException {
  if (input.hasToken(0)) {
    DoubleToken inputValue=(DoubleToken)input.get(0);
    double k;
    int M=_backward.length - 1;
    _forwardCache[0]=inputValue.doubleValue();
    for (int i=1; i <= M; i++) {
      k=_reflectionCoefs[M - i];
      _forwardCache[i]=k * _backwardCache[i] + _forwardCache[i - 1];
    }
    output.broadcast(new DoubleToken(_forwardCache[M]));
    for (int i=1; i < M; i++) {
      k=-_reflectionCoefs[M - 1 - i];
      _backwardCache[i]=_backwardCache[i + 1] + k * _forwardCache[i + 1];
    }
    _backwardCache[M]=_forwardCache[M];
  }
}
Program: 75723
Project: 75723
Buggy source:
/** 
 * Return a new array that is formed by applying an instance of a ComplexUnaryOperation to each element in the input matrix (op.operate(matrix[i][j])).
 */
public static final Complex[][] applyUnaryOperation(final ComplexUnaryOperation op,final Complex[][] matrix){
  int rows=_rows(matrix);
  int columns=_columns(matrix);
  Complex[][] returnValue=new Complex[rows][columns];
  for (int i=0; i < rows; i++) {
    for (int j=0; i < columns; j++) {
      returnValue[i][j]=op.operate(matrix[i][j]);
    }
  }
  return returnValue;
}

Fixed version (ground truth):
/** 
 * Return a new array that is formed by applying an instance of a ComplexUnaryOperation to each element in the input matrix (op.operate(matrix[i][j])).
 */
public static final Complex[][] applyUnaryOperation(final ComplexUnaryOperation op,final Complex[][] matrix){
  int rows=_rows(matrix);
  int columns=_columns(matrix);
  Complex[][] returnValue=new Complex[rows][columns];
  for (int i=0; i < rows; i++) {
    for (int j=0; j < columns; j++) {
      returnValue[i][j]=op.operate(matrix[i][j]);
    }
  }
  return returnValue;
}
Program: 75724
Project: 75724
Buggy source:
/** 
 * Return a new array that is formed by applying an instance of a ComplexBinaryOperation to the two matrices, element by element, using the elements of the first matrix as the left operands and the elements of the second matrix as the right operands. (op.operate(matrix1[i][j], matrix2[i][j])). If the matrices are not the same size, throw an IllegalArgumentException.
 */
public static final Complex[][] applyBinaryOperation(ComplexBinaryOperation op,final Complex[][] matrix1,final Complex[][] matrix2){
  int rows=_rows(matrix1);
  int columns=_columns(matrix1);
  _checkSameDimension("String_Node_Str",matrix1,matrix2);
  Complex[][] returnValue=new Complex[rows][columns];
  for (int i=0; i < rows; i++) {
    for (int j=0; i < columns; j++) {
      returnValue[i][j]=op.operate(matrix1[i][j],matrix2[i][j]);
    }
  }
  return returnValue;
}

Fixed version (ground truth):
/** 
 * Return a new array that is formed by applying an instance of a ComplexBinaryOperation to the two matrices, element by element, using the elements of the first matrix as the left operands and the elements of the second matrix as the right operands. (op.operate(matrix1[i][j], matrix2[i][j])). If the matrices are not the same size, throw an IllegalArgumentException.
 */
public static final Complex[][] applyBinaryOperation(ComplexBinaryOperation op,final Complex[][] matrix1,final Complex[][] matrix2){
  int rows=_rows(matrix1);
  int columns=_columns(matrix1);
  _checkSameDimension("String_Node_Str",matrix1,matrix2);
  Complex[][] returnValue=new Complex[rows][columns];
  for (int i=0; i < rows; i++) {
    for (int j=0; j < columns; j++) {
      returnValue[i][j]=op.operate(matrix1[i][j],matrix2[i][j]);
    }
  }
  return returnValue;
}
Program: 75725
Project: 75725
Buggy source:
/** 
 * Return the determinate of a square matrix. If the matrix is not square, throw an IllegalArgumentException. This algorithm uses LU decomposition, and is taken from [1]
 */
public static final double determinate(final double[][] matrix){
  _checkSquare("String_Node_Str",matrix);
  double[][] a;
  double det=1.0;
  int n=_rows(matrix);
  a=allocCopy(matrix);
  for (int pivot=0; pivot < n - 1; pivot++) {
    double big=Math.abs(a[pivot][pivot]);
    int swapRow=0;
    for (int row=pivot + 1; row < n; row++) {
      double absElement=Math.abs(a[row][pivot]);
      if (absElement > big) {
        swapRow=row;
        big=absElement;
      }
    }
    if (swapRow != 0) {
      double[] aPtr=a[pivot];
      a[pivot]=a[swapRow];
      a[swapRow]=aPtr;
      det*=-a[pivot][pivot];
    }
 else {
      det*=a[pivot][pivot];
    }
    if (Math.abs(det) <= 1E-50) {
      return det;
    }
    double pivotInverse=1.0 / a[pivot][pivot];
    for (int col=pivot + 1; col < n; col++) {
      a[pivot][col]*=pivotInverse;
    }
    for (int row=pivot + 1; row < n; row++) {
      double temp=a[row][pivot];
      for (int col=pivot + 1; col < n; col++) {
        a[row][col]-=a[pivot][col] * temp;
      }
    }
  }
  det*=a[n - 1][n - 1];
  return det;
}

Fixed version (ground truth):
/** 
 * Return the determinate of a square matrix. If the matrix is not square, throw an IllegalArgumentException. This algorithm uses LU decomposition, and is taken from [1]
 */
public static final double determinate(final double[][] matrix){
  _checkSquare("String_Node_Str",matrix);
  double[][] a;
  double det=1.0;
  int n=_rows(matrix);
  a=allocCopy(matrix);
  for (int pivot=0; pivot < n - 1; pivot++) {
    double big=Math.abs(a[pivot][pivot]);
    int swapRow=0;
    for (int row=pivot + 1; row < n; row++) {
      double absElement=Math.abs(a[row][pivot]);
      if (absElement > big) {
        swapRow=row;
        big=absElement;
      }
    }
    if (swapRow != 0) {
      double[] aPtr=a[pivot];
      a[pivot]=a[swapRow];
      a[swapRow]=aPtr;
      det*=-a[pivot][pivot];
    }
 else {
      det*=a[pivot][pivot];
    }
    if (Math.abs(det) <= Complex.epsilon) {
      return det;
    }
    double pivotInverse=1.0 / a[pivot][pivot];
    for (int col=pivot + 1; col < n; col++) {
      a[pivot][col]*=pivotInverse;
    }
    for (int row=pivot + 1; row < n; row++) {
      double temp=a[row][pivot];
      for (int col=pivot + 1; col < n; col++) {
        a[row][col]-=a[pivot][col] * temp;
      }
    }
  }
  det*=a[n - 1][n - 1];
  return det;
}
Program: 75726
Project: 75726
Buggy source:
/** 
 * Replace the first matrix argument's values, in the specified row and column range, with the second matrix argument's values, starting from specified row and column of the second matrix.
 * @param srcMatrix A matrix of doubles, used as the destination.
 * @param srcRowStart An int specifying the starting row of the source.
 * @param srcColStart An int specifying the starting column of thesource.
 * @param destMatrix A matrix of doubles, used as the destination.
 * @param destRowStart An int specifying the starting row of the dest.
 * @param destColStart An int specifying the starting column of thedest.
 * @param rowSpan An int specifying how many rows to copy.
 * @param colSpan An int specifying how many columns to copy.
 */
public static final void matrixCopy(final double[][] srcMatrix,final int srcRowStart,final int srcColStart,final double[][] destMatrix,final int destRowStart,final int destColStart,final int rowSpan,final int colSpan){
  for (int i=0; i < rowSpan; i++) {
    System.arraycopy(srcMatrix[srcRowStart + i],srcColStart,destMatrix[destRowStart + i],destColStart,colSpan);
  }
}

Fixed version (ground truth):
/** 
 * Replace the destinationMatrix argument's values, in the specified row and column range, with the sourceMatrix argument's values, starting from specified row and column of the second matrix.
 * @param sourceMatrix A matrix of doubles, used as the destination.
 * @param sourceRowStart An int specifying the starting row of the source.
 * @param sourceColStart An int specifying the starting column of thesource.
 * @param destinationMatrix A matrix of doubles, used as the destination.
 * @param destinationRowStart An int specifying the starting row of thedestination. 
 * @param destinationColumnStart An int specifying the starting columnof the destination.
 * @param rowSpan An int specifying how many rows to copy.
 * @param columnSpan An int specifying how many columns to copy.
 */
public static final void matrixCopy(final double[][] sourceMatrix,final int sourceRowStart,final int sourceColStart,final double[][] destinationMatrix,final int destinationRowStart,final int destinationColumnStart,final int rowSpan,final int columnSpan){
  for (int i=0; i < rowSpan; i++) {
    System.arraycopy(sourceMatrix[sourceRowStart + i],sourceColStart,destinationMatrix[destinationRowStart + i],destinationColumnStart,columnSpan);
  }
}
Program: 75727
Project: 75727
Buggy source:
/** 
 * Return a new array that is formed by applying an instance of a FloatUnaryOperation to each element in the input matrix (op.operate(matrix[i][j])).
 */
public static final float[][] applyUnaryOperation(final FloatUnaryOperation op,final float[][] matrix){
  int rows=_rows(matrix);
  int columns=_columns(matrix);
  float[][] returnValue=new float[rows][columns];
  for (int i=0; i < rows; i++) {
    for (int j=0; i < columns; j++) {
      returnValue[i][j]=op.operate(matrix[i][j]);
    }
  }
  return returnValue;
}

Fixed version (ground truth):
/** 
 * Return a new array that is formed by applying an instance of a FloatUnaryOperation to each element in the input matrix (op.operate(matrix[i][j])).
 */
public static final float[][] applyUnaryOperation(final FloatUnaryOperation op,final float[][] matrix){
  int rows=_rows(matrix);
  int columns=_columns(matrix);
  float[][] returnValue=new float[rows][columns];
  for (int i=0; i < rows; i++) {
    for (int j=0; j < columns; j++) {
      returnValue[i][j]=op.operate(matrix[i][j]);
    }
  }
  return returnValue;
}