nus-yam/ex-repair huggingface dataset:
Program: 72500
Project: 72500
Buggy source:
/** 
 * Display the specified tokens. If the display is not a MatrixPane, or the tokens are not instances of MatrixToken, do nothing.
 * @exception IllegalActionException If the tokens are notinstances of ImageToken.
 */
@Override public void append(List list) throws IllegalActionException {
  Iterator tokens=list.iterator();
  while (tokens.hasNext()) {
    Object token=tokens.next();
    if (token instanceof ImageToken) {
      display((ImageToken)token);
    }
  }
}

Fixed version (ground truth):
/** 
 * Display the specified tokens. If the tokens are not instances of ImageToken, do nothing.
 * @exception IllegalActionException If the tokens are notinstances of ImageToken.
 */
@Override public void append(List list) throws IllegalActionException {
  Iterator tokens=list.iterator();
  while (tokens.hasNext()) {
    Object token=tokens.next();
    if (token instanceof ImageToken) {
      display((ImageToken)token);
    }
  }
}
Program: 72502
Project: 72502
Buggy source:
@Override public void handle(Buffer body){
synchronized (_actor) {
    _currentObj.callMember("String_Node_Str",_response,body.toString());
  }
}

Fixed version (ground truth):
public void handle(Buffer body){
  if (isText) {
    _currentObj.callMember("String_Node_Str",response,body.toString());
  }
 else   if (contentType.startsWith("String_Node_Str")) {
    InputStream stream=new ByteArrayInputStream(body.getBytes());
    try {
      Image image=ImageIO.read(stream);
      Token token=new AWTImageToken(image);
      _currentObj.callMember("String_Node_Str",response,token);
    }
 catch (    IOException e) {
      _currentObj.callMember("String_Node_Str",response,body.getBytes());
    }
  }
 else {
    _currentObj.callMember("String_Node_Str",response,body.getBytes());
  }
}
Program: 72507
Project: 72507
Buggy source:
/** 
 * Close the web socket.
 */
public synchronized void close(){
  if (_webSocket != null) {
    if (_wsIsOpen) {
      _webSocket.close();
    }
    _webSocket=null;
  }
  if (_pendingOutputs != null && _pendingOutputs.size() > 0) {
    _currentObj.callMember("String_Node_Str","String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Close the web socket.
 */
public synchronized void close(){
  new Exception("String_Node_Str").printStackTrace();
  if (_webSocket != null) {
    if (_wsIsOpen) {
      try {
        _webSocket.close();
      }
 catch (      IllegalStateException ex) {
      }
    }
    _webSocket=null;
  }
  if (_pendingOutputs != null && _pendingOutputs.size() > 0) {
    _currentObj.callMember("String_Node_Str","String_Node_Str","String_Node_Str");
  }
}
Program: 72508
Project: 72508
Buggy source:
/** 
 * Trigger quantization-events if necessary. <p>Update the external, quantized state models.</p>
 * @param currentTime The current simulation time.
 * @param forceAll If true, requantize all state models.
 */
private final void _triggerQuantizationEvents(final Time currentTime,final boolean forceAll) throws IllegalActionException {
  final int stateCt=_qssSolver.getStateCount();
  if (_debugging) {
    _debugToStdOut(String.format("String_Node_Str",System.identityHashCode(this),currentTime.toString()));
  }
  int qIdx=-1;
  while (true) {
    if (forceAll) {
      qIdx++;
      if (qIdx >= stateCt) {
        break;
      }
    }
 else {
      qIdx=_qssSolver.needQuantizationEventIndex();
      if (qIdx < 0) {
        break;
      }
    }
    _qssSolver.triggerQuantizationEvent(qIdx);
    final TypedIOPort outPort=_fmiModelDescription.continuousStates.get(qIdx).port;
    _sendModelToPort(_qssSolver.getStateModel(qIdx).coeffs,outPort,currentTime);
    if (_debugging) {
      _debugToStdOut(String.format("String_Node_Str",System.identityHashCode(this),qIdx,_qssSolver.getStateModel(qIdx).toString()));
    }
  }
  _produceOutputs(currentTime);
}

Fixed version (ground truth):
/** 
 * Trigger quantization-events if necessary. <p>Update the external, quantized state models.</p>
 * @param currentTime The current simulation time.
 * @param forceAll If true, requantize all state models.
 */
private final void _triggerQuantizationEvents(final Time currentTime,final boolean forceAll) throws IllegalActionException {
  final int stateCt=_qssSolver.getStateCount();
  List<Boolean> needQuantizationEvents=new LinkedList<Boolean>();
  if (_debugging) {
    _debugToStdOut(String.format("String_Node_Str",System.identityHashCode(this),currentTime.toString()));
  }
  int qIdx=-1;
  while (true) {
    if (forceAll) {
      qIdx++;
      if (qIdx >= stateCt) {
        break;
      }
    }
 else {
      qIdx=_qssSolver.needQuantizationEventIndex();
      if (qIdx < 0) {
        break;
      }
    }
    _qssSolver.triggerQuantizationEvent(qIdx);
    final TypedIOPort outPort=_fmiModelDescription.continuousStates.get(qIdx).port;
    needQuantizationEvents.add(true);
    _sendModelToPort(_qssSolver.getStateModel(qIdx).coeffs,outPort,currentTime);
    if (_debugging) {
      _debugToStdOut(String.format("String_Node_Str",System.identityHashCode(this),qIdx,_qssSolver.getStateModel(qIdx).toString()));
    }
  }
  final double[] stateVariables=new double[stateCt];
  if (_firstRound || needQuantizationEvents.contains(true)) {
    for (int i=0; i < stateCt; i++) {
      stateVariables[i]=_qssSolver.getStateModel(i).coeffs[0];
    }
    _fmiSetContinuousStates(stateVariables);
  }
  _produceOutputs(currentTime);
}
Program: 72509
Project: 72509
Buggy source:
/** 
 * Initialize the   {@link PtolemyFederateAmbassadorInner} which handlesthe communication from RTI -> to RTIA -> to FEDERATE. The <i>rtia</i> manages the interaction with the external communicant process RTIA. This method called the Declaration Management services provide by HLA/CERTI to publish/subscribe to HLA attributes in a HLA Federation.
 * @param rtia
 * @throws NameNotFound
 * @throws ObjectClassNotDefined
 * @throws FederateNotExecutionMember
 * @throws RTIinternalError
 * @throws AttributeNotDefined
 * @throws SaveInProgress
 * @throws RestoreInProgress
 * @throws ConcurrentAccessAttempted All those exceptions are from the HLA/CERTI implementation.
 */
public void initialize(RTIambassador rtia) throws NameNotFound, ObjectClassNotDefined, FederateNotExecutionMember, RTIinternalError, AttributeNotDefined, SaveInProgress, RestoreInProgress, ConcurrentAccessAttempted {
  this.timeAdvanceGrant=false;
  this.timeConstrained=false;
  this.timeRegulator=false;
  this.synchronizationSuccess=false;
  this.synchronizationFailed=false;
  this.inPause=false;
  setUpHlaPublisher(rtia);
  setUpHLASubscriber(rtia);
}

Fixed version (ground truth):
/** 
 * Initialize the   {@link PtolemyFederateAmbassadorInner} which handlesthe communication from RTI -> to RTIA -> to FEDERATE. The <i>rtia</i> manages the interaction with the external communicant process RTIA. This method called the Declaration Management services provide by HLA/CERTI to publish/subscribe to HLA attributes in a HLA Federation.
 * @param rtia
 * @throws NameNotFound
 * @throws ObjectClassNotDefined
 * @throws FederateNotExecutionMember
 * @throws RTIinternalError
 * @throws AttributeNotDefined
 * @throws SaveInProgress
 * @throws RestoreInProgress
 * @throws ConcurrentAccessAttempted All those exceptions are from the HLA/CERTI implementation.
 */
public void initialize(RTIambassador rtia) throws NameNotFound, ObjectClassNotDefined, FederateNotExecutionMember, RTIinternalError, AttributeNotDefined, SaveInProgress, RestoreInProgress, ConcurrentAccessAttempted {
  this.timeAdvanceGrant=false;
  this.timeConstrained=false;
  this.timeRegulator=false;
  this.synchronizationSuccess=false;
  this.synchronizationFailed=false;
  this.inPause=false;
  setUpHlaPublisher(rtia);
  setUpSubscription(rtia);
}
Program: 72517
Project: 72517
Buggy source:
/** 
 * Each tokens, received in the input port, are transmitted to the  {@link HlaManager} for a publication to the HLA/CERTI Federation.
 */
@Override public void fire() throws IllegalActionException {
  for (int i=0; i < input.getWidth(); ++i) {
    if (input.hasToken(i)) {
      Token in=input.get(i);
      String actorName=input.sourcePortList().get(i).getContainer().getName();
      String fedName=((StringToken)_hlaManager.federateName.getToken()).stringValue();
      int id=_registeredObject.get(fedName + "String_Node_Str" + actorName);
      _hlaManager.updateHlaAttribute(this,in,id);
      if (_debugging) {
        _debug(this.getDisplayName() + "String_Node_Str" + in.toString()+ "String_Node_Str"+ this.getName()+ "String_Node_Str"+ _hlaManager.getDisplayName()+ "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Each tokens, received in the input port, are transmitted to the  {@link HlaManager} for a publication to the HLA/CERTI Federation.
 */
@Override public void fire() throws IllegalActionException {
  for (int i=0; i < input.getWidth(); ++i) {
    if (input.hasToken(i)) {
      Token in=input.get(i);
      _hlaManager.updateHlaAttribute(this,in,input.sourcePortList().get(i).getContainer().getName());
      if (_debugging) {
        _debug(this.getDisplayName() + "String_Node_Str" + in.toString()+ "String_Node_Str"+ this.getName()+ "String_Node_Str"+ _hlaManager.getDisplayName()+ "String_Node_Str");
      }
    }
  }
}
Program: 72518
Project: 72518
Buggy source:
public void addPortSinks(IOPort port){
  relations.putIfAbsent(port.getName(),new HashSet<IOPort>());
  relations.get(port.getName()).addAll(port.sinkPortList());
}

Fixed version (ground truth):
public void addPortSinks(IOPort port){
  if (!relations.containsKey(port.getName())) {
    relations.put(port.getName(),new HashSet<IOPort>());
  }
  relations.get(port.getName()).addAll(port.sinkPortList());
}
Program: 72522
Project: 72522
Buggy source:
/** 
 * Parse the ModelStructure to catch the I/O direct dependencies.
 * @param node The node to be parsed
 */
public void parseDependenciese(Node node){
  NamedNodeMap attributes=node.getAttributes();
  Long valueReference=Long.parseLong(attributes.getNamedItem("String_Node_Str").getNodeValue()) - 1;
  Node dependencyNode=attributes.getNamedItem("String_Node_Str");
  if (dependencyNode != null && dependencyNode.getNodeValue().trim().length() != 0) {
    String[] dependencies=dependencyNode.getNodeValue().trim().split("String_Node_Str");
    for (int i=0; i < modelVariables.size(); i++) {
      if (modelVariables.get(i).valueReference == valueReference) {
        modelVariables.get(i).directDependency.clear();
        for (int j=0; j < dependencies.length; j++) {
          for (int k=0; k < modelVariables.size(); k++) {
            try {
              if (modelVariables.get(k).valueReference == (Long.parseLong(dependencies[j]) - 1) && modelVariables.get(k).causality.equals(Causality.input)) {
                modelVariables.get(i).directDependency.add(modelVariables.get(k).name);
                break;
              }
            }
 catch (            NumberFormatException ex) {
              NumberFormatException nfx=new NumberFormatException("String_Node_Str" + dependencies[j] + "String_Node_Str"+ j+ "String_Node_Str");
              nfx.initCause(ex);
              throw nfx;
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Parse the ModelStructure to catch the I/O direct dependencies.
 * @param node The node  to be parsed
 */
public void parseDependenciese(Node node){
  NamedNodeMap attributes=node.getAttributes();
  Long valueReference=modelVariables.get(Integer.parseInt(attributes.getNamedItem("String_Node_Str").getNodeValue()) - 1).valueReference;
  Node dependencyNode=attributes.getNamedItem("String_Node_Str");
  if (dependencyNode != null) {
    String[] dependencies;
    if (dependencyNode.getNodeValue().trim().length() != 0) {
      dependencies=dependencyNode.getNodeValue().trim().split("String_Node_Str");
    }
 else {
      dependencies=new String[0];
    }
    for (int i=0; i < modelVariables.size(); i++) {
      if (modelVariables.get(i).valueReference == valueReference) {
        modelVariables.get(i).directDependency.clear();
        for (int j=0; j < dependencies.length; j++) {
          for (int k=0; k < modelVariables.size(); k++) {
            try {
              if (modelVariables.get(k).valueReference == modelVariables.get(Integer.parseInt(dependencies[j]) - 1).valueReference && modelVariables.get(k).causality.equals(Causality.input)) {
                modelVariables.get(i).directDependency.add(modelVariables.get(k).name);
                break;
              }
            }
 catch (            NumberFormatException ex) {
              NumberFormatException nfx=new NumberFormatException("String_Node_Str" + dependencies[j] + "String_Node_Str"+ j+ "String_Node_Str");
              nfx.initCause(ex);
              throw nfx;
            }
          }
        }
      }
    }
  }
}
Program: 72524
Project: 72524
Buggy source:
@Override protected void _execute() throws IllegalActionException {
  CompositeActor container=(CompositeActor)classToInstantiate.getContainer();
  try {
    Instantiable instance;
    LinkedList<ComponentEntity> actors=_freeActors.get(classHandle);
    if (actors.size() == 0) {
      instance=classToInstantiate.instantiate(container,objectName);
      container.notifyConnectivityChange();
      _newlyCreated.add(instance);
    }
 else {
      instance=actors.poll();
      if (_debugging) {
        _debug(instance.getName() + "String_Node_Str" + objectHandle);
      }
    }
    CompositeActor newActor=(CompositeActor)instance;
    List<HlaSubscriber> subscribers=newActor.entityList(HlaSubscriber.class);
    for (int i=0; i < subscribers.size(); ++i) {
      HlaSubscriber sub=subscribers.get(i);
      sub.objectName.setExpression("String_Node_Str" + objectName + "String_Node_Str");
      ;
      sub.objectHandle=objectHandle;
      _hlaAttributesSubscribedTo.put(sub.getIdentity(),new Object[]{sub.output,sub.output.getType(),"String_Node_Str",classHandle,sub.attributeHandle});
      _fromFederationEvents.put(sub.getIdentity(),new LinkedList<TimedEvent>());
    }
  }
 catch (  NameDuplicationException|CloneNotSupportedException ex) {
    ex.printStackTrace();
  }
}

Fixed version (ground truth):
@Override protected void _execute() throws IllegalActionException {
  CompositeActor container=(CompositeActor)classToInstantiate.getContainer();
  try {
    Instantiable instance;
    LinkedList<ComponentEntity> actors=_freeActors.get(classHandle);
    if (actors.size() == 0) {
      instance=classToInstantiate.instantiate(container,objectName);
      container.notifyConnectivityChange();
      _newlyCreated.add(instance);
    }
 else {
      instance=actors.poll();
      if (_debugging) {
        _debug(instance.getName() + "String_Node_Str" + objectHandle);
      }
    }
    CompositeActor newActor=(CompositeActor)instance;
    List<HlaSubscriber> subscribers=newActor.entityList(HlaSubscriber.class);
    for (int i=0; i < subscribers.size(); ++i) {
      HlaSubscriber sub=subscribers.get(i);
      sub.objectName.setExpression("String_Node_Str" + objectName + "String_Node_Str");
      ;
      sub.setObjectHandle(objectHandle);
      _hlaAttributesSubscribedTo.put(sub.getIdentity(),new Object[]{sub.output,sub.output.getType(),"String_Node_Str",classHandle,sub.getAttributeHandle()});
      _fromFederationEvents.put(sub.getIdentity(),new LinkedList<TimedEvent>());
    }
  }
 catch (  NameDuplicationException|CloneNotSupportedException ex) {
    ex.printStackTrace();
  }
}
Program: 72528
Project: 72528
Buggy source:
@Override public void wrapup() throws IllegalActionException {
  super.wrapup();
  attributeHandle=Integer.MIN_VALUE;
  classHandle=Integer.MIN_VALUE;
  objectHandle=Integer.MIN_VALUE;
}

Fixed version (ground truth):
@Override public void wrapup() throws IllegalActionException {
  super.wrapup();
  setAttributeHandle(Integer.MIN_VALUE);
  setClassHandle(Integer.MIN_VALUE);
  setObjectHandle(Integer.MIN_VALUE);
}
Program: 72530
Project: 72530
Buggy source:
/** 
 * Clone the actor into the specified workspace.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  HlaSubscriber newObject=(HlaSubscriber)super.clone(workspace);
  newObject._reflectedAttributeValues=new LinkedList<TimedEvent>();
  newObject._useCertiMessageBuffer=_useCertiMessageBuffer;
  newObject.attributeHandle=attributeHandle;
  newObject.classHandle=classHandle;
  newObject.objectHandle=Integer.MIN_VALUE;
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  HlaSubscriber newObject=(HlaSubscriber)super.clone(workspace);
  newObject._reflectedAttributeValues=new LinkedList<TimedEvent>();
  newObject._useCertiMessageBuffer=_useCertiMessageBuffer;
  newObject.setAttributeHandle(getAttributeHandle());
  newObject.setClassHandle(getClassHandle());
  newObject.setObjectHandle(Integer.MIN_VALUE);
  return newObject;
}
Program: 72531
Project: 72531
Buggy source:
/** 
 * Send each update value of the HLA attribute (mapped to this actor) as token when its time.
 * @exception IllegalActionException Not thrown here.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  Time currentTime=getDirector().getModelTime();
  Iterator<TimedEvent> it=_reflectedAttributeValues.iterator();
  while (it.hasNext()) {
    TimedEvent te=it.next();
    if (te.timeStamp.compareTo(currentTime) == 0) {
      Token content=_buildToken((Object[])te.contents);
      int origin=-1;
      if (te instanceof OriginatedEvent) {
        OriginatedEvent oe=(OriginatedEvent)te;
        origin=oe.objectID;
      }
      if (origin == -1 || origin == objectHandle) {
        this.outputPortList().get(0).send(0,content);
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ getParameterName()+ "String_Node_Str"+ origin+ "String_Node_Str"+ te.timeStamp+ "String_Node_Str"+ content.toString()+ "String_Node_Str");
        }
      }
      it.remove();
    }
  }
}

Fixed version (ground truth):
/** 
 * Send each update value of the HLA attribute (mapped to this actor) as token when its time.
 * @exception IllegalActionException Not thrown here.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  Time currentTime=getDirector().getModelTime();
  Iterator<TimedEvent> it=_reflectedAttributeValues.iterator();
  while (it.hasNext()) {
    TimedEvent te=it.next();
    if (te.timeStamp.compareTo(currentTime) == 0) {
      Token content=_buildToken((Object[])te.contents);
      int origin=-1;
      if (te instanceof OriginatedEvent) {
        OriginatedEvent oe=(OriginatedEvent)te;
        origin=oe.objectID;
      }
      if (origin == -1 || origin == getObjectHandle()) {
        this.outputPortList().get(0).send(0,content);
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ getParameterName()+ "String_Node_Str"+ origin+ "String_Node_Str"+ te.timeStamp+ "String_Node_Str"+ content.toString()+ "String_Node_Str");
        }
      }
      it.remove();
    }
  }
}
Program: 72537
Project: 72537
Buggy source:
/** 
 * Each tokens, received in the input port, are transmitted to the  {@link HlaManager} for a publication to the HLA/CERTI Federation.
 */
@Override public void fire() throws IllegalActionException {
  for (int i=0; i < input.getWidth(); ++i) {
    if (input.hasToken(i)) {
      Token in=input.get(i);
      String name=input.sourcePortList().get(i).getContainer().getDisplayName();
      _hlaManager.updateHlaAttribute(this,in,_registeredObject.get(name));
      if (_debugging) {
        _debug(this.getDisplayName() + "String_Node_Str" + in.toString()+ "String_Node_Str"+ this.getName()+ "String_Node_Str"+ _hlaManager.getDisplayName()+ "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Each tokens, received in the input port, are transmitted to the  {@link HlaManager} for a publication to the HLA/CERTI Federation.
 */
@Override public void fire() throws IllegalActionException {
  for (int i=0; i < input.getWidth(); ++i) {
    if (input.hasToken(i)) {
      Token in=input.get(i);
      String actorName=input.sourcePortList().get(i).getContainer().getName();
      String fedName=((StringToken)_hlaManager.federateName.getToken()).stringValue();
      int id=_registeredObject.get(fedName + "String_Node_Str" + actorName);
      _hlaManager.updateHlaAttribute(this,in,id);
      if (_debugging) {
        _debug(this.getDisplayName() + "String_Node_Str" + in.toString()+ "String_Node_Str"+ this.getName()+ "String_Node_Str"+ _hlaManager.getDisplayName()+ "String_Node_Str");
      }
    }
  }
}
Program: 72540
Project: 72540
Buggy source:
/** 
 * Clone the actor into the specified workspace.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  RecordAssembler newObject=(RecordAssembler)super.clone(workspace);
  newObject._portMap=new HashMap<String,TypedIOPort>();
  return newObject;
}

Fixed version (ground truth):
/** 
 * Clone the actor into the specified workspace.
 * @param workspace The workspace for the new object.
 * @return A new actor.
 * @exception CloneNotSupportedException If a derived class containsan attribute that cannot be cloned.
 */
@Override public Object clone(Workspace workspace) throws CloneNotSupportedException {
  RecordAssembler newObject=(RecordAssembler)super.clone(workspace);
  newObject._portMap=_newPortMap();
  return newObject;
}
Program: 72541
Project: 72541
Buggy source:
/** 
 * Map port names or aliases to port objects. If the mapping has changed, then invalidate the resolved types, which forces new type constraints with appropriate field names to be generated.
 */
protected void _mapPorts(){
  Manager manager=this.getManager();
  Map<String,TypedIOPort> oldMap=_portMap;
  _portMap=new HashMap<String,TypedIOPort>();
  for (  TypedIOPort p : this.inputPortList()) {
    String name=p.getName();
    String alias=p.getDisplayName();
    if (p.numberOfSources() < 1) {
      continue;
    }
    if (alias == null || alias.equals("String_Node_Str")) {
      _portMap.put(name,p);
    }
 else {
      _portMap.put(alias,p);
    }
  }
  if (manager != null && (oldMap == null || !_portMap.equals(oldMap))) {
    manager.invalidateResolvedTypes();
  }
}

Fixed version (ground truth):
/** 
 * Map port names or aliases to port objects. If the mapping has changed, then invalidate the resolved types, which forces new type constraints with appropriate field names to be generated.
 */
protected void _mapPorts(){
  Manager manager=this.getManager();
  Map<String,TypedIOPort> oldMap=_portMap;
  _portMap=_newPortMap();
  for (  TypedIOPort p : this.inputPortList()) {
    String name=p.getName();
    String alias=p.getDisplayName();
    if (p.numberOfSources() < 1) {
      continue;
    }
    if (alias == null || alias.equals("String_Node_Str")) {
      _portMap.put(name,p);
    }
 else {
      _portMap.put(alias,p);
    }
  }
  if (manager != null && (oldMap == null || !_portMap.equals(oldMap))) {
    manager.invalidateResolvedTypes();
  }
}
Program: 72544
Project: 72544
Buggy source:
/** 
 * Return the input port dependency for a given output port.
 * @param port The output port for which you want the inputdependency list
 * @return the list of input ports that directly influence thevalue of the given output port. If port is not an output port return null.
 */
public Set<String> getInputDependencyList(String port){
  Set<String> inputVariables=null;
  for (int i=0; i < _fmiModelDescription.modelVariables.size(); i++) {
    if (_fmiModelDescription.modelVariables.get(i).name.equals(port)) {
      if (_fmiModelDescription.modelVariables.get(i).name.equals(port)) {
        inputVariables=_fmiModelDescription.modelVariables.get(i).directDependency;
      }
    }
  }
  return inputVariables;
}

Fixed version (ground truth):
/** 
 * Return the input port dependency for a given output port.
 * @param port The output port for which you want the inputdependency list
 * @return the list of input ports that directly influence thevalue of the given output port. If port is not an output port return null.
 */
public List<FMIScalarVariable> getInputDependencyList(FMIScalarVariable scalar){
  List<FMIScalarVariable> inputVariables=new ArrayList<FMIScalarVariable>();
  if (scalar != null) {
    for (    String inputScalarName : scalar.directDependency) {
      for (      FMIScalarVariable inputVar : _fmiModelDescription.modelVariables) {
        if (inputVar.name.equals(inputScalarName))         inputVariables.add(inputVar);
      }
    }
  }
  return inputVariables;
}
Program: 72546
Project: 72546
Buggy source:
/** 
 * Get the persistent value for the specified channel, if there is one. If the persistent value is a SmoothToken, the first extrapolate its value to the current time.
 * @param channelIndex The channel.
 * @return The persistent value, or null if there isn't one.
 */
private Token _getPersistentValue(int channelIndex){
  if (_persistentToken != null) {
    return _persistentToken;
  }
 else   if (_persistentTokens != null && _persistentTokens.length > channelIndex && _persistentTokens[channelIndex] != null) {
    Token result=_persistentTokens[channelIndex];
    if (result instanceof SmoothToken) {
      Actor container=(Actor)getContainer();
      if (container != null) {
        Director director=container.getDirector();
        if (director != null) {
          Time currentTime=director.getModelTime();
          return ((SmoothToken)result).extrapolate(currentTime);
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Get the persistent value for the specified channel, if there is one. If the persistent value is a SmoothToken, the first extrapolate its value to the current time.
 * @param channelIndex The channel.
 * @return The persistent value, or null if there isn't one.
 */
private Token _getPersistentValue(int channelIndex){
  if (_persistentToken != null) {
    return _persistentToken;
  }
 else   if (_persistentTokens != null && _persistentTokens.length > channelIndex && _persistentTokens[channelIndex] != null) {
    Token result=_persistentTokens[channelIndex];
    if (result instanceof SmoothToken) {
      Actor container=(Actor)getContainer();
      if (container != null) {
        Director director=container.getDirector();
        if (director != null) {
          Time currentTime=director.getModelTime();
          return ((SmoothToken)result).extrapolate(currentTime);
        }
      }
    }
 else {
      return _persistentTokens[channelIndex];
    }
  }
  return null;
}
Program: 72547
Project: 72547
Buggy source:
/** 
 * Convert the left-hand argument to an array of size one. Then do an element-wise addition with each element of the right-hand argument. This method is only invoked when addition is attempted using a  base type left-hand argument (e.g., 1 + {1, 2, 3} which will  yield {2, 3, 4}.
 * @param leftArgument The array to add this array to.
 * @return The result of the addition.
 * @exception IllegalActionException If addition between this array and the provided argument is not supported.
 */
@Override public Token addReverse(Token leftArgument) throws IllegalActionException {
  try {
    Token[] arr={leftArgument};
    return new ArrayToken(arr).add(this);
  }
 catch (  IllegalActionException ex) {
    throw new IllegalActionException(null,ex,notSupportedMessage("String_Node_Str",this,leftArgument));
  }
}

Fixed version (ground truth):
/** 
 * If the left-hand argument is a base type token, then convert it  to an array of size one. Then do an element-wise addition with  each element of the right-hand argument. This method is only invoked when addition is attempted using a  base type left-hand argument (e.g., 1 + {1, 2, 3} which will  yield {2, 3, 4}.
 * @param leftArgument The array to add this array to.
 * @return The result of the addition.
 * @exception IllegalActionException If addition between this array and the provided argument is not supported.
 */
@Override public Token addReverse(Token leftArgument) throws IllegalActionException {
  try {
    int typeInfo=TypeLattice.compare(leftArgument,BaseType.STRING);
    if ((typeInfo == CPO.LOWER || typeInfo == CPO.SAME)) {
      Token[] arr={leftArgument};
      return new ArrayToken(arr).add(this);
    }
 else     if (getClass() == leftArgument.getClass()) {
      return ((ArrayToken)leftArgument).add(this);
    }
 else {
      throw new IllegalActionException(null,notSupportedMessage("String_Node_Str",this,leftArgument));
    }
  }
 catch (  IllegalActionException ex) {
    throw new IllegalActionException(null,ex,notSupportedMessage("String_Node_Str",this,leftArgument));
  }
}
Program: 72548
Project: 72548
Buggy source:
/** 
 * Set the type of the given node to be the return type of the method determined for the given node.
 * @param node The specified node.
 * @exception IllegalActionException If an inference error occurs.
 */
@Override public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException {
  Type[] childTypes=_inferAllChildren(node);
  if (childTypes.length == 1 && childTypes[0] instanceof RecordType) {
    RecordType type=(RecordType)childTypes[0];
    if (type.labelSet().contains(node.getMethodName())) {
      _setType(node,type.get(node.getMethodName()));
      return;
    }
  }
  _setType(node,_methodCall(node.getMethodName(),childTypes));
}

Fixed version (ground truth):
/** 
 * Set the type of the given node to be the return type of the method determined for the given node.
 * @param node The specified node.
 * @exception IllegalActionException If an inference error occurs.
 */
@Override public void visitMethodCallNode(ASTPtMethodCallNode node) throws IllegalActionException {
  Type[] childTypes=_inferAllChildren(node);
  if (childTypes.length == 1 && childTypes[0] instanceof RecordType) {
    RecordType type=(RecordType)childTypes[0];
    if (type.labelSet().contains(node.getMethodName())) {
      _setType(node,type.get(node.getMethodName()));
      return;
    }
  }
  if (childTypes.length == 1 && childTypes[0] == BaseType.UNKNOWN) {
    _setType(node,BaseType.UNKNOWN);
  }
 else {
    _setType(node,_methodCall(node.getMethodName(),childTypes));
  }
}
Program: 72549
Project: 72549
Buggy source:
/** 
 * Copy object files from $PTII/ptolemy/cg/adapter/generic/program/procedural/c/mbed/lib.
 */
private void _mbedCopy() throws IllegalActionException {
  File directory=codeDirectory.asFile();
  String mbedLibraryDirectory="String_Node_Str";
  try {
    File cgLibDirectory=new File(codeDirectory.asFile(),"String_Node_Str");
    if (!cgLibDirectory.mkdirs()) {
      throw new java.io.FileNotFoundException("String_Node_Str" + cgLibDirectory + "String_Node_Str");
    }
    String[] objectFiles=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    for (    String objectFile : objectFiles) {
      _copyCFileTosrc(mbedLibraryDirectory,cgLibDirectory.getCanonicalPath() + "String_Node_Str",objectFile);
    }
  }
 catch (  Throwable throwable) {
    throw new IllegalActionException(getComponent(),throwable,"String_Node_Str" + mbedLibraryDirectory + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Copy object files from $PTII/ptolemy/cg/adapter/generic/program/procedural/c/mbed/lib.
 */
private void _mbedCopy() throws IllegalActionException {
  File cgLibDirectory=new File(codeDirectory.asFile(),"String_Node_Str");
  String mbedLibraryDirectory="String_Node_Str";
  try {
    if (!cgLibDirectory.mkdirs()) {
      throw new java.io.FileNotFoundException("String_Node_Str" + cgLibDirectory + "String_Node_Str");
    }
    String[] objectFiles=new String[]{"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    for (    String objectFile : objectFiles) {
      _copyCFileTosrc(mbedLibraryDirectory,cgLibDirectory.getCanonicalPath() + "String_Node_Str",objectFile);
    }
  }
 catch (  Throwable throwable) {
    throw new IllegalActionException(getComponent(),throwable,"String_Node_Str" + mbedLibraryDirectory + "String_Node_Str"+ cgLibDirectory+ "String_Node_Str");
  }
}
Program: 72550
Project: 72550
Buggy source:
/** 
 * Fire the actor actor at the current model time or, if synchronizeToRealTime is enabled, fire the actor at the model time that corresponds to the current real time. This model time is computed by subtracting the model start time recorded by this director at the beginning of the simulation from the  system time and dividing by 1000, as the default unit of time is seconds.
 * @param actor The actor to be fired.
 * @return The model time the actor will be fired at.
 * @exception IllegalActionException If thrown while creating a Time objector while calling fireAt.
 */
@Override public Time fireAtCurrentTime(Actor actor) throws IllegalActionException {
  if (_synchronizeToRealTime) {
    Time modelTimeForCurrentRealTime=new Time(this,(System.currentTimeMillis() - this.getRealStartTimeMillis()) / 1000);
    return fireAt(actor,modelTimeForCurrentRealTime);
  }
 else {
    return super.fireAtCurrentTime(actor);
  }
}

Fixed version (ground truth):
/** 
 * Fire the actor actor at the current model time or, if synchronizeToRealTime is enabled, fire the actor at the model time that corresponds to the current real time. This model time is computed by subtracting the model start time recorded by this director at the beginning of the simulation from the  system time and dividing by 1000, as the default unit of time is seconds.
 * @param actor The actor to be fired.
 * @return The model time the actor will be fired at.
 * @exception IllegalActionException If thrown while creating a Time objector while calling fireAt.
 */
@Override public Time fireAtCurrentTime(Actor actor) throws IllegalActionException {
  if (_synchronizeToRealTime) {
    long elapsedTime=System.currentTimeMillis() - _realStartTime;
    Time modelTimeForCurrentRealTime=new Time(this,(double)elapsedTime / 1000);
    return fireAt(actor,modelTimeForCurrentRealTime);
  }
 else {
    return super.fireAtCurrentTime(actor);
  }
}
Program: 72553
Project: 72553
Buggy source:
/** 
 * Remove all events with the same tag and at the same actor from the event queue.
 * @param event The event.
 * @return A list of all events with same tag and at the same actor as theevent.
 */
private List<PtidesEvent> _removeEventsFromQueue(DEEventQueue queue,PtidesEvent event){
  List<PtidesEvent> eventList=new ArrayList<PtidesEvent>();
  int i=0;
  while (i < queue.size()) {
    PtidesEvent eventInQueue=((PtidesListEventQueue)queue).get(i);
    if (eventInQueue.hasTheSameTagAs(event) && eventInQueue.actor().equals(event.actor())) {
      eventList.add(eventInQueue);
      IOPort port=eventInQueue.ioPort();
      if (port != null) {
        _numberOfTokensPerPort.put(port,_numberOfTokensPerPort.get(port) - 1);
      }
      ((PtidesListEventQueue)queue).take(i);
      continue;
    }
    i++;
  }
  return eventList;
}

Fixed version (ground truth):
/** 
 * Remove all events with the same tag and at the same actor from the event queue.
 * @param event The event.
 * @return A list of all events with same tag and at the same actor as theevent.
 */
private List<PtidesEvent> _removeEventsFromQueue(DEEventQueue queue,PtidesEvent event){
  List<PtidesEvent> eventList=new ArrayList<PtidesEvent>();
  int i=0;
  while (i < queue.size()) {
    PtidesEvent eventInQueue=((PtidesListEventQueue)queue).get(i);
    if (eventInQueue.actor().equals(event.actor()) && eventInQueue.hasTheSameTagAs(event)) {
      eventList.add(eventInQueue);
      IOPort port=eventInQueue.ioPort();
      if (port != null) {
        _numberOfTokensPerPort.put(port,_numberOfTokensPerPort.get(port) - 1);
      }
      ((PtidesListEventQueue)queue).take(i);
      continue;
    }
    i++;
  }
  return eventList;
}
Program: 72554
Project: 72554
Buggy source:
@Override public boolean hasTheSameTagAs(DEEvent event){
  Actor actor=event.actor();
  if (actor == null) {
    actor=(Actor)event.ioPort().getContainer();
  }
  Double clockSyncBound=null;
  try {
    clockSyncBound=PtidesDirector._getDoubleParameterValue((NamedObj)actor,"String_Node_Str");
  }
 catch (  IllegalActionException e) {
  }
  if (clockSyncBound == null) {
    clockSyncBound=0.0;
  }
  boolean same=false;
  if (clockSyncBound == 0.0) {
    same=_timestamp.compareTo(event.timeStamp()) == 0 && _microstep == event.microstep();
  }
 else {
    same=_timestamp.subtract(clockSyncBound).compareTo(event.timeStamp()) <= 0 && _timestamp.add(clockSyncBound).compareTo(event.timeStamp()) >= 0;
    same=same & _microstep == event.microstep();
  }
  return same;
}

Fixed version (ground truth):
/** 
 * Compare event timestamp and microstep.
 * @param event The event to compare with.
 */
@Override public boolean hasTheSameTagAs(DEEvent event){
  if (event == this) {
    return true;
  }
  Actor actor=event.actor();
  if (actor == null) {
    actor=(Actor)event.ioPort().getContainer();
  }
  boolean same=_timestamp.compareTo(event.timeStamp()) == 0 && _microstep == event.microstep();
  return same;
}
Program: 72557
Project: 72557
Buggy source:
/** 
 * Construct a new instance of this integrator.
 * @param container The container.
 * @param name The name.
 * @exception IllegalActionException If setting up ports and parameters fails.
 * @exception NameDuplicationException If the container already contains an object with this name.
 */
public QSSIntegrator(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  u=new TypedIOPort(this,"String_Node_Str",true,false);
  u.setTypeEquals(BaseType.DOUBLE);
  q=new TypedIOPort(this,"String_Node_Str",false,true);
  q.setTypeEquals(BaseType.DOUBLE);
  xInit=new Parameter(this,"String_Node_Str");
  xInit.setTypeEquals(BaseType.DOUBLE);
  xInit.setExpression("String_Node_Str");
  quantum=new Parameter(this,"String_Node_Str");
  quantum.setTypeEquals(BaseType.DOUBLE);
  quantum.setExpression("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Construct a new instance of this integrator.
 * @param container The container.
 * @param name The name.
 * @exception IllegalActionException If setting up ports and parameters fails.
 * @exception NameDuplicationException If the container already contains an object with this name.
 */
public QSSIntegrator(CompositeEntity container,String name) throws IllegalActionException, NameDuplicationException {
  super(container,name);
  u=new TypedIOPort(this,"String_Node_Str",true,false);
  u.setTypeEquals(BaseType.DOUBLE);
  q=new TypedIOPort(this,"String_Node_Str",false,true);
  q.setTypeEquals(BaseType.DOUBLE);
  xInit=new Parameter(this,"String_Node_Str");
  xInit.setTypeEquals(BaseType.DOUBLE);
  xInit.setExpression("String_Node_Str");
  errorTolerance=new Parameter(this,"String_Node_Str");
  errorTolerance.setTypeEquals(BaseType.DOUBLE);
}
Program: 72558
Project: 72558
Buggy source:
/** 
 * If it is time to produce a quantized output, produce it. Otherwise, indicate that the output is absent.
 * @exception IllegalActionException If sending an output fails.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  Time currentTime=getDirector().getModelTime();
  if (_debugging) {
    _debug("String_Node_Str" + currentTime);
  }
  assert(_qssSolver.needQuantizationEventIndex() == -1);
  if (_qssSolver.getCurrentSimulationTime().compareTo(currentTime) < 0) {
    try {
      _qssSolver.stepToTime(currentTime);
    }
 catch (    Exception ee) {
      throw new IllegalActionException(this,ee,ee.getMessage());
    }
    if (_qssSolver.needQuantizationEventIndex() >= 0) {
      _qssSolver.triggerQuantizationEvent(0);
      if (q.getWidth() > 0) {
        double[] model=_qssSolver.getStateModel(0).coeffs;
        q.send(0,new SmoothToken(model[0]));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * If it is time to produce a quantized output, produce it. Otherwise, indicate that the output is absent.
 * @exception IllegalActionException If sending an output fails.
 */
@Override public void fire() throws IllegalActionException {
  super.fire();
  Time currentTime=getDirector().getModelTime();
  if (_debugging) {
    _debug("String_Node_Str" + currentTime);
  }
  assert(_qssSolver.needQuantizationEventIndex() == -1);
  if (_qssSolver.getCurrentSimulationTime().compareTo(currentTime) < 0) {
    try {
      _qssSolver.stepToTime(currentTime);
    }
 catch (    Exception ee) {
      throw new IllegalActionException(this,ee,ee.getMessage());
    }
    if (_qssSolver.needQuantizationEventIndex() >= 0) {
      _qssSolver.triggerQuantizationEvent(0);
      if (q.getWidth() > 0) {
        double[] model=_qssSolver.getStateModel(0).coeffs;
        q.send(0,new SmoothToken(model[0]));
      }
    }
  }
 else   if (_firstRound) {
    double[] model=_qssSolver.getStateModel(0).coeffs;
    q.send(0,new SmoothToken(model[0]));
  }
}
Program: 72559
Project: 72559
Buggy source:
/** 
 * Initialize this actor to indicate that no input has yet been provided.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  Director director=getDirector();
  if (!(director instanceof QSSDirector)) {
    throw new IllegalActionException(this,String.format("String_Node_Str",director.getName()));
  }
  _director=(QSSDirector)director;
  final Time currentTime=_director.getModelTime();
  _qssSolver=_director.newQSSSolver();
  _qssSolver.initializeDerivativeFunction(this);
  _qssSolver.initializeSimulationTime(currentTime);
  _qssSolver.setQuantizationEventTimeMaximum(_director.getModelStopTime());
  double xInitValue=((DoubleToken)xInit.getToken()).doubleValue();
  _qssSolver.setStateValue(0,xInitValue);
  double tolerance=_director.getErrorTolerance();
  _qssSolver.setQuantizationTolerance(0,tolerance,tolerance);
  getDirector().fireAtCurrentTime(this);
  _firstRound=true;
}

Fixed version (ground truth):
/** 
 * Initialize this actor to indicate that no input has yet been provided.
 */
@Override public void initialize() throws IllegalActionException {
  super.initialize();
  Director director=getDirector();
  if (!(director instanceof QSSDirector)) {
    throw new IllegalActionException(this,String.format("String_Node_Str",director.getName()));
  }
  _director=(QSSDirector)director;
  final Time currentTime=_director.getModelTime();
  _qssSolver=_director.newQSSSolver();
  _qssSolver.initializeDerivativeFunction(this);
  _qssSolver.initializeSimulationTime(currentTime);
  _qssSolver.setQuantizationEventTimeMaximum(_director.getModelStopTime());
  double xInitValue=((DoubleToken)xInit.getToken()).doubleValue();
  _qssSolver.setStateValue(0,xInitValue);
  double tolerance=_director.getErrorTolerance();
  DoubleToken toleranceToken=(DoubleToken)errorTolerance.getToken();
  if (toleranceToken != null) {
    tolerance=toleranceToken.doubleValue();
  }
  _qssSolver.setQuantizationTolerance(0,tolerance,tolerance);
  getDirector().fireAtCurrentTime(this);
  _firstRound=true;
  _lastFireAtTime=null;
}
Program: 72565
Project: 72565
Buggy source:
/** 
 * Read lines from the _inputStream and output them. 
 */
@Override public void run(){
  try {
    InputStreamReader inputStreamReader=new InputStreamReader(_inputStream);
    BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
    String line=null;
    while ((line=bufferedReader.readLine()) != null) {
      _fmuBuilder.stdout(line);
    }
  }
 catch (  IOException ioe) {
    _fmuBuilder.stderr("String_Node_Str" + ioe);
  }
}

Fixed version (ground truth):
/** 
 * Read lines from the _inputStream and output them. 
 */
@Override public void run(){
  try {
    InputStreamReader inputStreamReader=new InputStreamReader(_inputStream,Charset.defaultCharset());
    BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
    String line=null;
    while ((line=bufferedReader.readLine()) != null) {
      _fmuBuilder.stdout(line);
    }
  }
 catch (  IOException ioe) {
    _fmuBuilder.stderr("String_Node_Str" + ioe);
  }
}
Program: 72570
Project: 72570
Buggy source:
/** 
 * Read the content of a given file and return it to the caller as a string.
 * @param file The file that we need to read its content.
 * @return A string representation of the content of the model.
 * @exception IOException Thrown if there is an error reading the content ofthe file.
 */
private String _getContent(File file) throws IOException {
  StringBuilder contents=new StringBuilder();
  BufferedReader input=new BufferedReader(new FileReader(file));
  try {
    String line=null;
    while ((line=input.readLine()) != null) {
      contents.append(line);
      contents.append(System.getProperty("String_Node_Str"));
    }
  }
  finally {
    input.close();
  }
  return contents.toString();
}

Fixed version (ground truth):
/** 
 * Read the content of a given file and return it to the caller as a string.
 * @param file The file that we need to read its content.
 * @return A string representation of the content of the model.
 * @exception IOException Thrown if there is an error reading the content ofthe file.
 */
private String _getContent(File file) throws IOException {
  StringBuilder contents=new StringBuilder();
  BufferedReader input=new BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file),java.nio.charset.Charset.defaultCharset()));
  try {
    String line=null;
    while ((line=input.readLine()) != null) {
      contents.append(line);
      contents.append(System.getProperty("String_Node_Str"));
    }
  }
  finally {
    input.close();
  }
  return contents.toString();
}