nus-yam/ex-repair huggingface dataset:
Program: 72707
Project: 72707
Buggy source:
/** 
 * Iterate through resource mapping output ports and if they contain tokens, inform the director of the actors in the tokens that these actors can resume execution.
 * @exception illegalActionException Not explicitly thrown here.
 */
@Override public boolean postfire() throws IllegalActionException {
  boolean postfire=super.postfire();
  for (  Object entity : entityList()) {
    if (entity instanceof ExecutionResponsePort) {
      ExecutionResponsePort outputPort=((ExecutionResponsePort)entity);
      if (outputPort.hasToken() && outputPort.getToken() instanceof RecordToken) {
        RecordToken recordToken=(RecordToken)outputPort.getToken();
        if (recordToken.get("String_Node_Str") != null && ((ObjectToken)recordToken.get("String_Node_Str")).getValue() != null) {
          Actor actor=(Actor)((ObjectToken)recordToken.get("String_Node_Str")).getValue();
          notifyExecutionListeners((NamedObj)actor,getExecutiveDirector().getModelTime().getDoubleValue(),ExecutionEventType.STOP);
          outputPort.takeToken();
          _currentlyExecuting.remove(actor);
          actor.getExecutiveDirector().resumeActor((NamedObj)actor);
          _lastActorFinished=true;
        }
      }
    }
  }
  return postfire;
}

Fixed version (ground truth):
/** 
 * Iterate through resource mapping output ports and if they contain tokens, inform the director of the actors in the tokens that these actors can resume execution.
 * @exception illegalActionException Not explicitly thrown here.
 */
@Override public boolean postfire() throws IllegalActionException {
  boolean postfire=super.postfire();
  for (  Object entity : entityList()) {
    if (entity instanceof ExecutionResponsePort) {
      ExecutionResponsePort outputPort=((ExecutionResponsePort)entity);
      if (outputPort.hasToken() && outputPort.getToken() instanceof RecordToken) {
        RecordToken recordToken=(RecordToken)outputPort.getToken();
        if (recordToken.get("String_Node_Str") != null && ((ObjectToken)recordToken.get("String_Node_Str")).getValue() != null) {
          NamedObj actor=(NamedObj)((ObjectToken)recordToken.get("String_Node_Str")).getValue();
          notifyExecutionListeners(actor,getExecutiveDirector().getModelTime().getDoubleValue(),ExecutionEventType.STOP);
          outputPort.takeToken();
          _currentlyExecuting.remove(actor);
          Director director=null;
          if (actor instanceof Actor) {
            director=((Actor)actor).getExecutiveDirector();
          }
 else {
            Nameable container=actor.getContainer();
            while (!(container instanceof Actor)) {
              container=container.getContainer();
            }
            director=((Actor)container).getDirector();
          }
          director.resumeActor(actor);
          _lastActorFinished=true;
        }
      }
    }
  }
  return postfire;
}
Program: 72708
Project: 72708
Buggy source:
/** 
 * Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.
 * @param target The NamedObj that will be decorated.
 * @return The decorated attributes for the target NamedObj, ornull if the specified target is not an Actor.
 */
@Override public DecoratorAttributes createDecoratorAttributes(NamedObj target){
  if (target instanceof NamedObj && !_isPartOfExecutionAspect(target)) {
    try {
      return new CompositeExecutionAspectAttributes(target,this);
    }
 catch (    KernelException ex) {
      throw new InternalErrorException(ex);
    }
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.
 * @param target The NamedObj that will be decorated.
 * @return The decorated attributes for the target NamedObj, ornull if the specified target is not an Actor.
 */
@Override public DecoratorAttributes createDecoratorAttributes(NamedObj target){
  if (!_isPartOfExecutionAspect(target)) {
    try {
      return new CompositeExecutionAspectAttributes(target,this);
    }
 catch (    KernelException ex) {
      throw new InternalErrorException(ex);
    }
  }
 else {
    return null;
  }
}
Program: 72709
Project: 72709
Buggy source:
/** 
 * Get the priority of the actor.
 * @param actor The actor.
 * @return The priority of the actor or, if the actor has no priorityassigned, the lowest priority.
 * @exception IllegalActionException Thrown if parameter cannot be read.
 */
protected double _getPriority(NamedObj actor) throws IllegalActionException {
  return ((IntToken)((Parameter)actor.getDecoratorAttribute(this,"String_Node_Str")).getToken()).intValue();
}

Fixed version (ground truth):
/** 
 * Get the priority of the actor.
 * @param actor The actor.
 * @return The priority of the actor or, if the actor has no priorityassigned, the lowest priority.
 * @exception IllegalActionException Thrown if parameter cannot be read.
 */
protected double _getPriority(NamedObj actor) throws IllegalActionException {
  Attribute attributes=actor.getDecoratorAttribute(this,"String_Node_Str");
  if (attributes == null || !(attributes instanceof Parameter)) {
    throw new IllegalActionException(this,"String_Node_Str" + actor.getName());
  }
  Token token=((Parameter)attributes).getToken();
  if (token == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
 else   if (!(token instanceof IntToken)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  return ((IntToken)token).intValue();
}
Program: 72710
Project: 72710
Buggy source:
/** 
 * Resume the execution of an actor that was previously blocked because it didn't have all the resources it needed for execution. This method puts an event into the queue for the current time.
 * @param actor The actor that resumes execution.
 * @exception IllegalActionException Not thrown here but in derived classes.
 */
@Override public void resumeActor(NamedObj actor) throws IllegalActionException {
  List<DEEvent> events=_actorsInExecution.get(actor);
  Time time=((CompositeActor)getExecutionAspect((NamedObj)actor).getContainer()).getDirector().getModelTime();
  DEEvent event=events.get(0);
  events.remove(event);
  _actorsInExecution.put((Actor)actor,events);
  if (event.ioPort() != null) {
    _enqueueTriggerEvent(event.ioPort(),time);
  }
 else {
    _enqueueEvent((Actor)actor,time,1);
  }
  fireContainerAt(time);
  if (_actorsFinished == null) {
    _actorsFinished=new ArrayList();
  }
  _actorsFinished.add((Actor)actor);
}

Fixed version (ground truth):
/** 
 * Resume the execution of an actor that was previously blocked because it didn't have all the resources it needed for execution. This method puts an event into the queue for the current time.
 * @param actor The actor that resumes execution.
 * @exception IllegalActionException Not thrown here but in derived classes.
 */
@Override public void resumeActor(NamedObj actor) throws IllegalActionException {
  List<DEEvent> events=_actorsInExecution.get(actor);
  ActorExecutionAspect aspect=getExecutionAspect(actor);
  if (aspect == null) {
    throw new IllegalActionException(this,"String_Node_Str" + actor.getName() + "String_Node_Str");
  }
  NamedObj container=aspect.getContainer();
  if (container == null) {
    throw new IllegalActionException(this,"String_Node_Str" + actor.getName());
  }
  Director director=((CompositeActor)container).getDirector();
  if (director == null) {
    throw new IllegalActionException(this,"String_Node_Str" + container.getName() + "String_Node_Str"+ actor.getName());
  }
  Time time=director.getModelTime();
  DEEvent event=events.get(0);
  events.remove(event);
  _actorsInExecution.put((Actor)actor,events);
  if (event.ioPort() != null) {
    _enqueueTriggerEvent(event.ioPort(),time);
  }
 else {
    _enqueueEvent((Actor)actor,time,1);
  }
  fireContainerAt(time);
  if (_actorsFinished == null) {
    _actorsFinished=new ArrayList();
  }
  _actorsFinished.add((Actor)actor);
}
Program: 72713
Project: 72713
Buggy source:
/** 
 * Override the base class to adjust the number of contained actors, if the number is no longer correct.
 * @param port The port that has connection changes.
 */
public void connectionsChanged(Port port){
  super.connectionsChanged(port);
  if (port == input) {
    Manager manager=getManager();
    if (manager != null && manager.getState() != Manager.IDLE && manager.getState() != Manager.INFERING_WIDTHS && manager.getState() != Manager.PREINITIALIZING) {
      _reinitializeInnerActors();
    }
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to adjust the number of contained actors, if the number is no longer correct.
 * @param port The port that has connection changes.
 */
public void connectionsChanged(Port port){
  super.connectionsChanged(port);
  if (port == input) {
    Manager manager=getManager();
    if (manager != null) {
      Manager.State managerState=manager.getState();
      if (managerState == Manager.ITERATING || managerState == Manager.PAUSED || managerState == Manager.PAUSED_ON_BREAKPOINT) {
        _reinitializeInnerActors();
      }
    }
  }
}
Program: 72714
Project: 72714
Buggy source:
/** 
 * Open a URL of web service that is protected by OAuth 2.0.
 * @param url The protected URL on a Resource server. Usually this is some kind of RESTful API.
 * @param accessToken The code used to prove access authorization to the Resource server.
 * @return
 * @throws IllegalActionException 
 */
public String readProtectedURL(String url,String accessToken) throws IllegalActionException {
  OAuthResourceResponse resourceResponse=null;
  try {
    OAuthClientRequest bearerClientRequest=new OAuthBearerClientRequest(url).setAccessToken(accessToken).buildQueryMessage();
    OAuthClient client=new OAuthClient(new URLConnectionClient());
    resourceResponse=client.resource(bearerClientRequest,OAuth.HttpMethod.GET,OAuthResourceResponse.class);
  }
 catch (  OAuthSystemException ex) {
    throw new IllegalActionException(null,ex,"String_Node_Str" + ex.getMessage());
  }
catch (  OAuthProblemException ex2) {
    throw new IllegalActionException(null,ex2,"String_Node_Str" + ex2.getMessage());
  }
  if (resourceResponse != null) {
    if (resourceResponse.getResponseCode() == 200) {
      return resourceResponse.getBody();
    }
  }
  return "String_Node_Str" + resourceResponse.getResponseCode() + "String_Node_Str"+ resourceResponse.getBody();
}

Fixed version (ground truth):
/** 
 * Open a URL of web service that is protected by OAuth 2.0.
 * @param url The protected URL on a Resource server. Usually this is some kind of RESTful API.
 * @param accessToken The code used to prove access authorization to the Resource server.
 * @return
 * @throws IllegalActionException 
 */
public String readProtectedURL(String url,String accessToken) throws IllegalActionException {
  OAuthResourceResponse resourceResponse=null;
  try {
    OAuthClientRequest bearerClientRequest=new OAuthBearerClientRequest(url).setAccessToken(accessToken).buildQueryMessage();
    OAuthClient client=new OAuthClient(new URLConnectionClient());
    resourceResponse=client.resource(bearerClientRequest,OAuth.HttpMethod.GET,OAuthResourceResponse.class);
  }
 catch (  OAuthSystemException ex) {
    throw new IllegalActionException(null,ex,"String_Node_Str" + ex.getMessage());
  }
catch (  OAuthProblemException ex2) {
    throw new IllegalActionException(null,ex2,"String_Node_Str" + ex2.getMessage());
  }
  if (resourceResponse != null) {
    if (resourceResponse.getResponseCode() == 200) {
      return resourceResponse.getBody();
    }
 else {
      return "String_Node_Str" + resourceResponse.getResponseCode() + "String_Node_Str"+ resourceResponse.getBody();
    }
  }
 else {
    throw new IllegalActionException("String_Node_Str");
  }
}
Program: 72716
Project: 72716
Buggy source:
protected void _updateEstimates(){
  _transitionMatrix=A_new;
  _sigma=s_new;
  _mu=m_new;
  _priorIn=_priors;
  _D=D_new;
  _durationPriors=dPrior_new;
}

Fixed version (ground truth):
protected void _updateEstimates(){
  _transitionMatrix=A_new;
  _sigma=s_new;
  _mu=m_new;
  _priorIn=prior_new;
  _D=D_new;
  _durationPriors=dPrior_new;
}
Program: 72717
Project: 72717
Buggy source:
protected boolean _checkForConvergence(int iterations){
  if ((m_new[0] != m_new[0]) || (s_new[0] != s_new[0]) || (A_new[0] != A_new[0])|| (prior_new[0] != prior_new[0])) {
    if ((iterations >= _nIterations - 1)) {
      m_new=_mu0;
      s_new=_sigma0;
      A_new=_A0;
      prior_new=_priors;
      System.out.println("String_Node_Str");
      return false;
    }
 else     if (_randomize) {
      double minO=_observations[0];
      double maxO=_observations[0];
      for (int t=0; t < _observations.length; t++) {
        if (_observations[t] < minO) {
          minO=_observations[t];
        }
        if (_observations[t] > maxO) {
          maxO=_observations[t];
        }
      }
      double L=maxO - minO;
      for (int i=0; i < _nStates; i++) {
        m_new[i]=L / _nStates * Math.random() + L * i / _nStates + minO;
        s_new[i]=Math.abs((maxO - minO) * Math.random()) / _nStates;
        for (int j=0; j < _nStates; j++) {
        }
      }
      A_new=_A0;
      Arrays.sort(m_new);
      prior_new=_priors;
    }
  }
  return true;
}

Fixed version (ground truth):
protected boolean _checkForConvergence(int iterations){
  boolean nanDetected=false;
  for (int i=0; i < m_new.length; i++) {
    if ((m_new[i] != m_new[i]) || (s_new[i] != s_new[i]) || (A_new[i][i] != A_new[i][i])|| (prior_new[i] != prior_new[i])|| (D_new[i] != D_new[i])) {
      nanDetected=true;
      break;
    }
  }
  if (nanDetected) {
    if ((iterations >= _nIterations - 1)) {
      m_new=_mu0;
      s_new=_sigma0;
      A_new=_A0;
      prior_new=_priors;
      _D=_D0;
      _durationPriors=_dPriors0;
      System.out.println("String_Node_Str");
      return false;
    }
 else     if (_randomize) {
      double minO=_observations[0];
      double maxO=_observations[0];
      for (int t=0; t < _observations.length; t++) {
        if (_observations[t] < minO) {
          minO=_observations[t];
        }
        if (_observations[t] > maxO) {
          maxO=_observations[t];
        }
      }
      double L=maxO - minO;
      for (int i=0; i < _nStates; i++) {
        m_new[i]=L / _nStates * Math.random() + L * i / _nStates + minO;
        s_new[i]=Math.abs((maxO - minO) * Math.random()) / _nStates;
        for (int j=0; j < _nStates; j++) {
        }
      }
      A_new=_A0;
      Arrays.sort(m_new);
      prior_new=_priors;
    }
 else {
      System.out.println("String_Node_Str");
      return false;
    }
  }
  return true;
}
Program: 72718
Project: 72718
Buggy source:
public void fire() throws IllegalActionException {
  super.fire();
  if ((_nStates != _sigma0.length) || (_nStates != _transitionMatrix.length) || (_nStates != _priors.length)|| (_nStates != _mu0.length)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _EMParameterEstimation();
  int _nObservations=_observations.length;
  Token[] mTokens=new Token[_nStates];
  Token[] sTokens=new Token[_nStates];
  Token[] pTokens=new Token[_nStates];
  Token[] cTokens=new Token[_nObservations];
  Token[] dTokens=new Token[_maxDuration];
  for (int i=0; i < _nStates; i++) {
    mTokens[i]=new DoubleToken(m_new[i]);
    sTokens[i]=new DoubleToken(s_new[i]);
    pTokens[i]=new DoubleToken(prior_new[i]);
  }
  for (int i=0; i < _maxDuration; i++) {
    dTokens[i]=new DoubleToken(dPrior_new[i]);
  }
  for (int i=0; i < _nObservations; i++) {
    cTokens[i]=new IntToken(clusters[i]);
  }
  mean.send(0,new ArrayToken(mTokens));
  standardDeviation.send(0,new ArrayToken(sTokens));
  transitionMatrix.send(0,new DoubleMatrixToken(A_new));
  priorEstimates.send(0,new ArrayToken(pTokens));
  durationEstimates.send(0,new DoubleMatrixToken(D_new));
  clusterAssignments.send(0,new ArrayToken(cTokens));
  durationPriorEstimates.send(0,new ArrayToken(dTokens));
}

Fixed version (ground truth):
public void fire() throws IllegalActionException {
  super.fire();
  if ((_nStates != _sigma0.length) || (_nStates != _transitionMatrix.length) || (_nStates != _priors.length)|| (_nStates != _mu0.length)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  _EMParameterEstimation();
  int _nObservations=_observations.length;
  Token[] mTokens=new Token[_nStates];
  Token[] sTokens=new Token[_nStates];
  Token[] pTokens=new Token[_nStates];
  Token[] cTokens=new Token[_nObservations];
  Token[] dTokens=new Token[_maxDuration];
  Token[] lTokens=new Token[_likelihoodHistory.size()];
  for (int i=0; i < _nStates; i++) {
    mTokens[i]=new DoubleToken(m_new[i]);
    sTokens[i]=new DoubleToken(s_new[i]);
    pTokens[i]=new DoubleToken(prior_new[i]);
  }
  for (int i=0; i < _maxDuration; i++) {
    dTokens[i]=new DoubleToken(dPrior_new[i]);
  }
  for (int i=0; i < _nObservations; i++) {
    cTokens[i]=new IntToken(clusters[i]);
  }
  for (int i=0; i < lTokens.length; i++) {
    lTokens[i]=new DoubleToken(_likelihoodHistory.get(i));
  }
  _likelihoodHistory.clear();
  mean.send(0,new ArrayToken(mTokens));
  standardDeviation.send(0,new ArrayToken(sTokens));
  transitionMatrix.send(0,new DoubleMatrixToken(A_new));
  priorEstimates.send(0,new ArrayToken(pTokens));
  durationEstimates.send(0,new DoubleMatrixToken(D_new));
  clusterAssignments.send(0,new ArrayToken(cTokens));
  durationPriorEstimates.send(0,new ArrayToken(dTokens));
  modelLikelihood.send(0,new ArrayToken(lTokens));
}
Program: 72719
Project: 72719
Buggy source:
/** 
 * Get inputs via an input port.
 * @param portWrapper A JavaScript wrapper for a Port.
 * @param channel A channel number, or NaN to use the default (0).
 */
public Object get(NativeJavaObject portWrapper,Double channel){
  int channelNumber=0;
  if (channel != null && !channel.isNaN()) {
    if (channel.doubleValue() % 1 == 0) {
      channelNumber=channel.intValue();
    }
 else {
      throw new InternalErrorException(JavaScript.this,null,"String_Node_Str" + channel);
    }
  }
  Object unwrappedPort=portWrapper.unwrap();
  if (unwrappedPort instanceof TypedIOPort) {
    TypedIOPort port=(TypedIOPort)unwrappedPort;
    if (!port.isInput()) {
      throw new InternalErrorException(JavaScript.this,null,"String_Node_Str" + port.getName() + "String_Node_Str");
    }
    try {
      if (port.getWidth() < 1) {
        return null;
      }
      if (!port.hasToken(channelNumber)) {
        return null;
      }
      return _wrapToken(port.get(channelNumber));
    }
 catch (    KernelException e) {
      throw new InternalErrorException(JavaScript.this,e,"String_Node_Str" + port.getName() + "String_Node_Str");
    }
  }
 else {
    throw new InternalErrorException(JavaScript.this,null,"String_Node_Str" + unwrappedPort.toString() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Get inputs via an input port.
 * @param portWrapper A JavaScript wrapper for a Port.
 * @param channel A channel number, or NaN to use the default (0).
 */
public Object get(NativeJavaObject portWrapper,Double channel){
  int channelNumber=0;
  if (channel != null && !channel.isNaN()) {
    if (channel.doubleValue() % 1 == 0) {
      channelNumber=channel.intValue();
    }
 else {
      throw new InternalErrorException(JavaScript.this,null,"String_Node_Str" + channel);
    }
  }
  Object unwrappedPort=portWrapper.unwrap();
  if (unwrappedPort instanceof TypedIOPort) {
    TypedIOPort port=(TypedIOPort)unwrappedPort;
    if (!port.isInput()) {
      throw new InternalErrorException(JavaScript.this,null,"String_Node_Str" + port.getName() + "String_Node_Str");
    }
    try {
      if (port.getWidth() < 1) {
        return null;
      }
      if (!port.hasToken(channelNumber)) {
        return null;
      }
      return _wrapToken(port.get(channelNumber));
    }
 catch (    KernelException e) {
      throw new InternalErrorException(JavaScript.this,e,"String_Node_Str" + port.getName() + "String_Node_Str");
    }
  }
 else   if (unwrappedPort instanceof PortParameter) {
    try {
      PortParameter parameter=(PortParameter)unwrappedPort;
      return _wrapToken(parameter.getToken());
    }
 catch (    KernelException e) {
      throw new InternalErrorException(JavaScript.this,e,"String_Node_Str" + ((PortParameter)unwrappedPort).getName() + "String_Node_Str");
    }
  }
 else {
    throw new InternalErrorException(JavaScript.this,null,"String_Node_Str" + unwrappedPort.toString() + "String_Node_Str");
  }
}
Program: 72729
Project: 72729
Buggy source:
/** 
 * Free the instance of the FMU.
 * @exception IllegalActionException If the FMU does not return fmiOK.
 */
protected void _fmiFreeInstance() throws IllegalActionException {
  if (_debugging) {
    _debugToStdOut("String_Node_Str");
  }
  int fmiFlag=0;
  if (_fmiModelDescription.modelExchange) {
    if (_fmiVersion >= 1.5 && _fmiVersion < 2.0) {
      fmiFlag=((Integer)_fmiFreeModelInstanceFunction.invokeInt(new Object[]{_fmiComponent})).intValue();
      if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
        throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
      }
    }
  }
 else {
    if (_fmiVersion < 2.0) {
      _fmiFreeSlaveInstanceFunction.invokeInt(new Object[]{_fmiComponent});
    }
 else {
    }
  }
}

Fixed version (ground truth):
/** 
 * Free the instance of the FMU.
 * @exception IllegalActionException If the FMU does not return fmiOK.
 */
protected void _fmiFreeInstance() throws IllegalActionException {
  if (_debugging) {
    _debugToStdOut("String_Node_Str");
  }
  if (_fmiVersion < 2.0) {
    if (_fmiModelDescription.modelExchange) {
      _fmiFreeModelInstanceFunction.invokeInt(new Object[]{_fmiComponent});
    }
 else {
      _fmiFreeSlaveInstanceFunction.invokeInt(new Object[]{_fmiComponent});
    }
  }
 else {
    _fmiFreeInstanceFunction.invokeInt(new Object[]{_fmiComponent});
  }
}
Program: 72734
Project: 72734
Buggy source:
/** 
 * Free the instance of the FMU.
 * @exception IllegalActionException If the FMU does not return fmiOK.
 */
protected void _fmiFreeInstance() throws IllegalActionException {
  if (_debugging) {
    _debugToStdOut("String_Node_Str");
  }
  int fmiFlag=0;
  if (_fmiModelDescription.modelExchange) {
    if (_fmiVersion >= 1.5 && _fmiVersion < 2.0) {
      fmiFlag=((Integer)_fmiFreeModelInstanceFunction.invokeInt(new Object[]{_fmiComponent})).intValue();
      if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
        throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
      }
    }
  }
 else {
    if (_fmiVersion < 2.0) {
      _fmiFreeSlaveInstanceFunction.invokeInt(new Object[]{_fmiComponent});
    }
 else {
    }
  }
}

Fixed version (ground truth):
/** 
 * Free the instance of the FMU.
 * @exception IllegalActionException If the FMU does not return fmiOK.
 */
protected void _fmiFreeInstance() throws IllegalActionException {
  if (_debugging) {
    _debugToStdOut("String_Node_Str");
  }
  int fmiFlag=0;
  if (_fmiVersion < 2.0) {
    if (_fmiModelDescription.modelExchange) {
      if (_fmiVersion >= 1.5 && _fmiVersion < 2.0) {
        fmiFlag=((Integer)_fmiFreeModelInstanceFunction.invokeInt(new Object[]{_fmiComponent})).intValue();
        if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
          throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
        }
      }
    }
 else {
      _fmiFreeSlaveInstanceFunction.invokeInt(new Object[]{_fmiComponent});
    }
  }
 else {
    _fmiFreeInstanceFunction.invokeInt(new Object[]{_fmiComponent});
  }
}
Program: 72738
Project: 72738
Buggy source:
/** 
 * Clone the object into the specified workspace. This overrides the base class to instantiate a new IterateDirector and to set the association with iterationCount.
 * @param workspace The workspace for the new object.
 * @return A new NamedObj.
 * @exception CloneNotSupportedException If any of the attributescannot be cloned.
 * @see #exportMoML(Writer,int,String)
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  CompositeOptimizer result=(CompositeOptimizer)super.clone(workspace);
  try {
    String directorName=null;
    Iterator directors=result.attributeList(OptimizerDirector.class).iterator();
    while (directors.hasNext()) {
      OptimizerDirector oldDirector=(OptimizerDirector)directors.next();
      if (directorName == null) {
        directorName=oldDirector.getName();
      }
      oldDirector.setContainer(null);
    }
    OptimizerDirector director=result.new OptimizerDirector(workspace);
    director.setContainer(result);
    director.setName(directorName);
  }
 catch (  Throwable throwable) {
    throw new CloneNotSupportedException("String_Node_Str" + throwable);
  }
  result._tokenMap=new HashMap<IOPort,Token>();
  return result;
}

Fixed version (ground truth):
/** 
 * Clone the object into the specified workspace. This overrides the base class to instantiate a new OptimizerDirector 
 * @param workspace The workspace for the new object.
 * @return A new NamedObj.
 * @exception CloneNotSupportedException If any of the attributescannot be cloned.
 * @see #exportMoML(Writer,int,String)
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  CompositeOptimizer result=(CompositeOptimizer)super.clone(workspace);
  try {
    String directorName=null;
    Iterator directors=result.attributeList(OptimizerDirector.class).iterator();
    while (directors.hasNext()) {
      OptimizerDirector oldDirector=(OptimizerDirector)directors.next();
      if (directorName == null) {
        directorName=oldDirector.getName();
      }
      oldDirector.setContainer(null);
    }
    OptimizerDirector director=result.new OptimizerDirector(workspace);
    director.setContainer(result);
    director.setName(directorName);
  }
 catch (  Throwable throwable) {
    throw new CloneNotSupportedException("String_Node_Str" + throwable);
  }
  result._tokenMap=new HashMap<IOPort,Token>();
  result._firstIteration=true;
  return result;
}
Program: 72741
Project: 72741
Buggy source:
/** 
 * For model exchange, set the continuous states of the FMU to the specified array.
 * @param values The values to assign to the states.
 * @exception IllegalActionException If the length of the array does not matchthe number of continuous states, or if the FMU does not return fmiOK.
 */
protected void _fmiSetContinuousStates(double values[]) throws IllegalActionException {
  if (values.length != _fmiModelDescription.numberOfContinuousStates) {
    throw new IllegalActionException(this,"String_Node_Str" + values.length + "String_Node_Str"+ _fmiModelDescription.numberOfContinuousStates);
  }
  DoubleBuffer states=DoubleBuffer.allocate(values.length);
  for (int i=0; i < values.length; i++) {
    states.put(values[i]);
  }
  int fmiFlag=((Integer)_fmiSetContinuousStates.invoke(Integer.class,new Object[]{_fmiComponent,states,new NativeSizeT(values.length)})).intValue();
  if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
    Time currentTime=getDirector().getModelTime();
    throw new IllegalActionException(this,"String_Node_Str" + currentTime + "String_Node_Str"+ _fmiStatusDescription(fmiFlag));
  }
  if (_debugging) {
    _debug("String_Node_Str" + java.util.Arrays.toString(values));
  }
}

Fixed version (ground truth):
/** 
 * For model exchange, set the continuous states of the FMU to the specified array.
 * @param values The values to assign to the states.
 * @exception IllegalActionException If the length of the array does not matchthe number of continuous states, or if the FMU does not return fmiOK.
 */
protected void _fmiSetContinuousStates(double values[]) throws IllegalActionException {
  if (values.length != _fmiModelDescription.numberOfContinuousStates) {
    throw new IllegalActionException(this,"String_Node_Str" + values.length + "String_Node_Str"+ _fmiModelDescription.numberOfContinuousStates);
  }
  int fmiFlag=((Integer)_fmiSetContinuousStates.invoke(Integer.class,new Object[]{_fmiComponent,values,new NativeSizeT(values.length)})).intValue();
  if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
    Time currentTime=getDirector().getModelTime();
    throw new IllegalActionException(this,"String_Node_Str" + currentTime + "String_Node_Str"+ _fmiStatusDescription(fmiFlag));
  }
  if (_debugging) {
    _debug("String_Node_Str" + java.util.Arrays.toString(values));
  }
}
Program: 72743
Project: 72743
Buggy source:
/** 
 * React to attribute changes.
 */
@Override public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == defaultValue) {
    _getMirrorPort().defaultValue.setExpression(defaultValue.getExpression());
  }
  super.attributeChanged(attribute);
}

Fixed version (ground truth):
/** 
 * React to attribute changes.
 */
@Override public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == defaultValue) {
    if (_getMirrorPort() != null) {
      _getMirrorPort().defaultValue.setExpression(defaultValue.getExpression());
    }
  }
  super.attributeChanged(attribute);
}
Program: 72744
Project: 72744
Buggy source:
private RefinementPort _getMirrorPort(){
  if (getContainer() != null && ((ModalModel)getContainer())._controller != null && ((ModalModel)getContainer())._controller.getPort(this.getName()) != null) {
    return (RefinementPort)((ModalModel)getContainer())._controller.getPort(this.getName());
  }
  return null;
}

Fixed version (ground truth):
private RefinementPort _getMirrorPort(){
  if (getContainer() != null && getContainer() instanceof ModalModel && ((ModalModel)getContainer())._controller != null && ((ModalModel)getContainer())._controller.getPort(this.getName()) != null) {
    if (((ModalModel)getContainer())._controller.getPort(this.getName()) instanceof RefinementPort) {
      return (RefinementPort)((ModalModel)getContainer())._controller.getPort(this.getName());
    }
  }
  return null;
}
Program: 72745
Project: 72745
Buggy source:
private ModalPort _getMirrorPort(){
  Nameable container=getContainer();
  if (container != null) {
    Nameable modal=container.getContainer();
    if (modal instanceof ModalModel) {
      return (ModalPort)((ModalModel)modal).getPort(getName());
    }
  }
  return null;
}

Fixed version (ground truth):
private ModalPort _getMirrorPort(){
  Nameable container=getContainer();
  if (container != null) {
    Nameable modal=container.getContainer();
    if (modal instanceof ModalModel) {
      if (((ModalModel)modal).getPort(getName()) instanceof ModalPort) {
        return (ModalPort)((ModalModel)modal).getPort(getName());
      }
    }
  }
  return null;
}
Program: 72746
Project: 72746
Buggy source:
/** 
 * Build the model. <p>Read the model "NCApplication.xml" from the current directory.
 * @param args Ignored
 * @exception Exception If there is a problem reading the model.
 */
public static void main(String[] args) throws Exception {
  CompositeEntity _toplevel;
  try {
    Workspace workspace=new Workspace("String_Node_Str");
    _toplevel=new CompositeEntity(workspace);
    _toplevel.setName("String_Node_Str");
    Counter counter=new Counter(_toplevel,"String_Node_Str");
    Leds leds=new Leds(_toplevel,"String_Node_Str");
    _toplevel.connect(counter.output,leds.display,"String_Node_Str");
    StringWriter buffer=new StringWriter();
    _toplevel.exportMoML(buffer);
    String fileName="String_Node_Str";
    FileOutputStream file=null;
    PrintStream out=null;
    try {
      file=new FileOutputStream(fileName);
      PrintStream out=new PrintStream(file);
      out.println(buffer);
      out.flush();
    }
  finally {
      if (out != null) {
        try {
          out.close();
        }
 catch (        Throwable throwable) {
          System.out.println("String_Node_Str" + "String_Node_Str" + fileName);
          throwable.printStackTrace();
        }
      }
    }
    counter.initialize();
    IntToken[] t=new IntToken[1];
    t[0]=new IntToken(2);
    TupleToken arg=new TupleToken(t);
    for (int i=0; i < 10; i++) {
      counter.increment.call(arg);
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    throw ex;
  }
}

Fixed version (ground truth):
/** 
 * Build the model. <p>Read the model "NCApplication.xml" from the current directory.
 * @param args Ignored
 * @exception Exception If there is a problem reading the model.
 */
public static void main(String[] args) throws Exception {
  CompositeEntity _toplevel;
  try {
    Workspace workspace=new Workspace("String_Node_Str");
    _toplevel=new CompositeEntity(workspace);
    _toplevel.setName("String_Node_Str");
    Counter counter=new Counter(_toplevel,"String_Node_Str");
    Leds leds=new Leds(_toplevel,"String_Node_Str");
    _toplevel.connect(counter.output,leds.display,"String_Node_Str");
    StringWriter buffer=new StringWriter();
    _toplevel.exportMoML(buffer);
    String fileName="String_Node_Str";
    FileOutputStream file=null;
    PrintStream out=null;
    try {
      file=new FileOutputStream(fileName);
      out=new PrintStream(file);
      out.println(buffer);
      out.flush();
    }
  finally {
      if (out != null) {
        try {
          out.close();
        }
 catch (        Throwable throwable) {
          System.out.println("String_Node_Str" + "String_Node_Str" + fileName);
          throwable.printStackTrace();
        }
      }
    }
    counter.initialize();
    IntToken[] t=new IntToken[1];
    t[0]=new IntToken(2);
    TupleToken arg=new TupleToken(t);
    for (int i=0; i < 10; i++) {
      counter.increment.call(arg);
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    throw ex;
  }
}
Program: 72747
Project: 72747
Buggy source:
private void _getFSMTransitionParameter() throws IllegalActionException {
  if (getContainer() != null) {
    FSMTransitionParameter fsmtp=(FSMTransitionParameter)getContainer().getAttribute(fsmTransitionParameterName.getValueAsString());
    try {
      if (_fsmTransitionParameter != null && _fsmTransitionParameter != fsmtp) {
        _fsmTransitionParameter.setContainer(null);
      }
      _fsmTransitionParameter=fsmtp;
      if (_fsmTransitionParameter == null) {
        try {
          _fsmTransitionParameter=new FSMTransitionParameter(getContainer(),fsmTransitionParameterName.getValueAsString(),this);
        }
 catch (        NameDuplicationException e) {
          throw new IllegalActionException(this,e.getCause(),e.getMessage());
        }
      }
      _fsmTransitionParameter.setTransition(this);
    }
 catch (    NameDuplicationException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
private void _getFSMTransitionParameter() throws IllegalActionException {
  if (getContainer() != null) {
    FSMTransitionParameter fsmtp=(FSMTransitionParameter)getContainer().getAttribute(fsmTransitionParameterName.getValueAsString());
    try {
      if (_fsmTransitionParameter != null && _fsmTransitionParameter != fsmtp) {
        _fsmTransitionParameter.setContainer(null);
      }
      _fsmTransitionParameter=fsmtp;
      if (_fsmTransitionParameter == null) {
        try {
          _fsmTransitionParameter=new FSMTransitionParameter(getContainer(),fsmTransitionParameterName.getValueAsString(),this);
        }
 catch (        NameDuplicationException e) {
          throw new IllegalActionException(this,e.getCause(),e.getMessage());
        }
      }
      if (_fsmTransitionParameter.getTransition() == null) {
        _fsmTransitionParameter.setTransition(this);
      }
    }
 catch (    NameDuplicationException e) {
      e.printStackTrace();
    }
  }
}
Program: 72750
Project: 72750
Buggy source:
public void sampleFromPrior() throws IllegalActionException {
  _parseTree=_updateTrees.get("String_Node_Str");
  for (int i=0; i < _ssSize; i++) {
    Token priorSample=_parseTreeEvaluator.evaluateParseTree(_parseTree,_scope);
    if (priorSample == null) {
      throw new IllegalActionException("String_Node_Str" + prior.getExpression());
    }
    double value=((DoubleToken)priorSample).doubleValue();
    _particleValue.add(value);
  }
}

Fixed version (ground truth):
public void sampleFromPrior() throws IllegalActionException {
  _parseTree=_updateTrees.get("String_Node_Str");
  for (int i=0; i < _ssSize; i++) {
    Token priorSample=_parseTreeEvaluator.evaluateParseTree(_parseTree,_scope);
    if (priorSample == null) {
      throw new IllegalActionException("String_Node_Str" + prior.getExpression());
    }
    double value=((DoubleToken)priorSample).doubleValue();
    _particleValue.add(Double.valueOf(value));
  }
}
Program: 72751
Project: 72751
Buggy source:
public Particle(int size){
  _particleValue=new LinkedList();
  _ssSize=size;
}

Fixed version (ground truth):
public Particle(int size){
  _particleValue=new LinkedList<Double>();
  _ssSize=size;
}
Program: 72754
Project: 72754
Buggy source:
public List getValue(){
  return _particleValue;
}

Fixed version (ground truth):
public List<Double> getValue(){
  return _particleValue;
}
Program: 72755
Project: 72755
Buggy source:
public void setValue(LinkedList l){
  _particleValue=new LinkedList();
  for (int i=0; i < l.size(); i++) {
    _particleValue.add(l.get(i));
  }
}

Fixed version (ground truth):
public void setValue(LinkedList<Double> l){
  _particleValue=new LinkedList<Double>();
  for (int i=0; i < l.size(); i++) {
    _particleValue.add(l.get(i));
  }
}
Program: 72758
Project: 72758
Buggy source:
private void _initializeParticles() throws IllegalActionException, NameDuplicationException {
  for (int i=0; i < particles.length; i++) {
    particles[i]=new Particle(_stateSpaceSize);
    particles[i].sampleFromPrior();
    particles[i].assignWeight();
  }
}

Fixed version (ground truth):
private void _initializeParticles() throws IllegalActionException, NameDuplicationException {
  for (int i=0; i < particles.length; i++) {
    particles[i]=new Particle(_stateSpaceSize);
    particles[i].sampleFromPrior();
    particles[i].assignWeight(_measurementEquation,_stateVariables);
  }
}
Program: 72763
Project: 72763
Buggy source:
/** 
 * Prepare for the next iteration, by making the current trigger token to be the history trigger token.
 * @return True always.
 * @exception IllegalActionException If thrown by the super class.
 */
public boolean postfire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  _lastTrigger=_thisTrigger;
  _eventMissed=false;
  if (_postponed > 0) {
    if (_debugging) {
      _debug("String_Node_Str");
    }
    getDirector().fireAtCurrentTime(this);
  }
  if (_postponedOutputProduced) {
    _postponedOutputProduced=false;
    ContinuousDirector dir=(ContinuousDirector)getDirector();
    int microstep=dir.getIndex();
    if (microstep == _postponed) {
      _postponed=0;
    }
  }
  return super.postfire();
}

Fixed version (ground truth):
/** 
 * Prepare for the next iteration, by making the current trigger token to be the history trigger token.
 * @return True always.
 * @exception IllegalActionException If thrown by the super class.
 */
public boolean postfire() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  _lastTrigger=_thisTrigger;
  _eventMissed=false;
  if (_postponed > 0) {
    if (_debugging) {
      _debug("String_Node_Str");
    }
    getDirector().fireAtCurrentTime(this);
  }
  if (_postponedOutputProduced) {
    _postponedOutputProduced=false;
    ContinuousDirector dir=(ContinuousDirector)getDirector();
    int microstep=dir.getIndex();
    if (microstep >= _postponed) {
      _postponed=0;
    }
  }
  return super.postfire();
}
Program: 72767
Project: 72767
Buggy source:
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  MathematicalModelConverter modelConverter=(MathematicalModelConverter)getContainer();
  Effigy effigy=parent == null ? null : ((TableauFrame)parent).getEffigy();
  Tableau tableau;
  try {
    if (effigy == null) {
      tableau=new Tableau(workspace());
      tableau.setName("String_Node_Str");
      tableau.setTitle("String_Node_Str");
    }
 else {
      tableau=(Tableau)effigy.getEntity("String_Node_Str");
      if (tableau == null) {
        tableau=new Tableau(effigy,"String_Node_Str");
      }
    }
  }
 catch (  KernelException e) {
    throw new InternalErrorException(e);
  }
  Frame frame=tableau.getFrame();
  if (frame == null) {
    try {
      frame=new MathematicalModelConverterGUI(modelConverter,tableau);
    }
 catch (    KernelException e) {
      throw new InternalErrorException(e);
    }
  }
  frame.setSize(800,350);
  frame.setResizable(false);
  frame.setLocationRelativeTo(null);
  frame.setVisible(true);
}

Fixed version (ground truth):
/** 
 * Create an editor for configuring the specified object with the specified parent window.
 * @param object The object to configure.
 * @param parent The parent window, or null if there is none.
 */
public void createEditor(NamedObj object,Frame parent){
  MathematicalModelConverter modelConverter=(MathematicalModelConverter)getContainer();
  Effigy effigy=parent == null ? null : ((TableauFrame)parent).getEffigy();
  Tableau tableau;
  try {
    if (effigy == null) {
      tableau=new Tableau(workspace());
      tableau.setName("String_Node_Str");
      tableau.setTitle("String_Node_Str");
    }
 else {
      tableau=(Tableau)effigy.getEntity("String_Node_Str");
      if (tableau == null) {
        tableau=new Tableau(effigy,"String_Node_Str");
      }
    }
  }
 catch (  KernelException e) {
    throw new InternalErrorException(e);
  }
  Frame frame=tableau.getFrame();
  if (frame == null) {
    try {
      frame=new MathematicalModelConverterGUI(modelConverter,tableau);
    }
 catch (    KernelException e) {
      throw new InternalErrorException(e);
    }
  }
  frame.pack();
  frame.setVisible(true);
}
Program: 72768
Project: 72768
Buggy source:
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == modelFileName) {
    StringToken modelFileNameToken=(StringToken)modelFileName.getToken();
    File modelFile=new File(modelFileNameToken.stringValue());
    if (!modelFile.exists()) {
      throw new IllegalActionException("String_Node_Str" + modelFileNameToken.stringValue() + "String_Node_Str");
    }
  }
 else   if (attribute == configFileName) {
    StringToken configFileNameToken=(StringToken)configFileName.getToken();
    File configFile=new File(configFileNameToken.stringValue());
    if (!configFile.exists()) {
      throw new IllegalActionException("String_Node_Str" + configFileNameToken.stringValue() + "String_Node_Str");
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}

Fixed version (ground truth):
public void attributeChanged(Attribute attribute) throws IllegalActionException {
  if (attribute == modelFileName) {
    File modelFile=modelFileName.asFile();
    if (modelFile.getName() != "String_Node_Str" && !modelFile.exists()) {
      throw new IllegalActionException("String_Node_Str" + modelFileName.getExpression() + "String_Node_Str");
    }
  }
 else   if (attribute == configFileName) {
    StringToken configFileNameToken=(StringToken)configFileName.getToken();
    File configFile=new File(configFileNameToken.stringValue());
    if (!configFile.exists()) {
      throw new IllegalActionException("String_Node_Str" + configFileNameToken.stringValue() + "String_Node_Str");
    }
  }
 else {
    super.attributeChanged(attribute);
  }
}
Program: 72770
Project: 72770
Buggy source:
/** 
 * Synchronizes the status of events from the pipe.
 * @param events the events to be synchronized from the pipe.
 */
public void syncEvents(LinkedList<Event.Builder> events){
  if (_debugging) {
    _debug("String_Node_Str");
  }
  events.clear();
  EventVector ev=null;
  try {
    FileInputStream fis=new FileInputStream(path + pipe2client);
    try {
      ev=EventVector.parseFrom(fis);
    }
  finally {
      fis.close();
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  for (  Event e : ev.getEventList()) {
    events.add(e.toBuilder());
  }
  if (_debugging) {
    for (    Builder etb : events) {
      _debug(etb.getName() + "String_Node_Str" + etb.getStatus().toString());
    }
  }
}

Fixed version (ground truth):
/** 
 * Synchronizes the status of events from the pipe.
 * @param events the events to be synchronized from the pipe.
 */
public void syncEvents(LinkedList<Event.Builder> events){
  if (_debugging) {
    _debug("String_Node_Str");
  }
  if (events == null) {
    throw new NullPointerException("String_Node_Str");
  }
  events.clear();
  EventVector ev=null;
  try {
    FileInputStream fis=new FileInputStream(path + pipe2client);
    try {
      ev=EventVector.parseFrom(fis);
    }
  finally {
      fis.close();
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  for (  Event e : ev.getEventList()) {
    events.add(e.toBuilder());
  }
  if (_debugging) {
    for (    Builder etb : events) {
      _debug(etb.getName() + "String_Node_Str" + etb.getStatus().toString());
    }
  }
}
Program: 72771
Project: 72771
Buggy source:
public void run(){
  String s=null;
  try {
    try {
      StringToken modelFileNameToken;
      StringToken configFileNameToken;
      try {
        modelFileNameToken=(StringToken)modelFileName.getToken();
        configFileNameToken=(StringToken)configFileName.getToken();
        System.out.println(modelFileNameToken.stringValue() + "String_Node_Str" + configFileNameToken.stringValue());
        process=Runtime.getRuntime().exec(modelFileNameToken.stringValue() + "String_Node_Str" + configFileNameToken.stringValue());
      }
 catch (      IllegalActionException e) {
        e.printStackTrace();
      }
      stdInput=new BufferedReader(new InputStreamReader(process.getInputStream()));
      while ((s=stdInput.readLine()) != null) {
        System.out.println(s);
      }
    }
  finally {
      stdInput.close();
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  String s=null;
  try {
    String command=null;
    try {
      StringToken modelFileNameToken;
      StringToken configFileNameToken;
      try {
        modelFileNameToken=(StringToken)modelFileName.getToken();
        configFileNameToken=(StringToken)configFileName.getToken();
        File modelFile=new File(modelFileNameToken.stringValue());
        if (!modelFile.exists()) {
          throw new IllegalActionException("String_Node_Str" + modelFileNameToken.stringValue() + "String_Node_Str");
        }
        command=modelFileNameToken.stringValue() + "String_Node_Str" + configFileNameToken.stringValue();
        System.out.println("String_Node_Str" + command);
        process=Runtime.getRuntime().exec(command);
      }
 catch (      IllegalActionException e) {
        e.printStackTrace();
      }
      stdInput=new BufferedReader(new InputStreamReader(process.getInputStream()));
      while ((s=stdInput.readLine()) != null) {
        System.out.println(s);
      }
    }
  finally {
      if (stdInput != null) {
        try {
          stdInput.close();
        }
 catch (        IOException ex) {
          System.err.println("String_Node_Str" + (command == null ? "String_Node_Str" : command) + "String_Node_Str");
        }
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}