Program: 72482
Project: 72482
Buggy source:
/** 
 * Initialize this FMU wrapper. <p>According to "System Design, Modeling, and Simulation Using Ptolemy II", version 1.02, section 12.3.1 "Execution Control": "The initialize action of the setup phase initializes parameters, resets local state, and sends out any initial messages."</p>
 * @exception IllegalActionException If the slave FMU cannot be initialized.
 */
public void initialize() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  if (_initializables != null) {
    for (    Initializable initializable : _initializables) {
      initializable.initialize();
    }
  }
  if (_debugging) {
    _debugToStdOut(String.format("String_Node_Str",System.identityHashCode(this)));
  }
  int fmiFlag;
  _firstRound=true;
  _quantumScaleFactor=_director.getQuantumScaleFactor();
  _internalRelativeQuantum=_director.getRelativeQuantum() * _quantumScaleFactor;
  if (_internalRelativeQuantum == 0.0) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  if (!_useRawJNI()) {
    if (((BooleanToken)initFMUParameters.getToken()).booleanValue() && !_useRawJNI()) {
      _initializeFMUParameters();
    }
    _fmiInitialize();
    _checkStateEvents();
    int newDiscreteStatesNeeded=1;
    int terminateSimulation=0;
    int nominalsOfContinuousStatesChanged=0;
    int valuesOfContinuousStatesChanged=0;
    int nextEventTimeDefined=0;
    double nextEventTime=0;
    _eventInfo=new FMI20EventInfo(newDiscreteStatesNeeded,terminateSimulation,nominalsOfContinuousStatesChanged,valuesOfContinuousStatesChanged,nextEventTimeDefined,nextEventTime);
    if (_fmiNewDiscreteStatesFunction == null) {
      throw new InternalErrorException(this,null,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + modelExchange + "String_Node_Str"+ _fmiModelDescription.modelExchange);
    }
    fmiFlag=((Integer)_fmiNewDiscreteStatesFunction.invoke(Integer.class,new Object[]{_fmiComponent,_eventInfo})).intValue();
    if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
      throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
    }
    if (_eventInfo.newDiscreteStatesNeeded != 0) {
      new Exception("String_Node_Str").printStackTrace();
    }
    if (_eventInfo.terminateSimulation != 0) {
      getDirector().finish();
    }
    fmiFlag=((Integer)_fmiEnterContinuousTimeModeFunction.invokeInt(new Object[]{_fmiComponent})).intValue();
    if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
      throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
    }
  }
 else {
    final String modelIdentifier=_fmiModelDescription.modelIdentifier;
    byte toBeVisible=0;
    if (((BooleanToken)visible.getToken()).booleanValue()) {
      toBeVisible=1;
    }
    byte loggingOn=_debugging ? (byte)1 : (byte)0;
    String fmuLibPath=null;
    try {
      fmuLibPath=_fmiModelDescription.getNativeLibraryPath();
    }
 catch (    IOException ex) {
      throw new IllegalActionException(this,ex,"String_Node_Str");
    }
    final Time currentTime=_director.getModelTime();
    final Time startTime=_director.getModelStartTime();
    final Time stopTime=_director.getModelStopTime();
    final double timeValue=currentTime.getDoubleValue();
    double[] derivatives=new double[_fmiModelDescription.numberOfContinuousStates];
    _fmiComponentJNI=_fmiInstantiatesJNI(modelIdentifier,fmuLibPath,_fmiModelDescription.fmuResourceLocation,startTime.getDoubleValue(),stopTime.getDoubleValue(),timeValue,0,_internalRelativeQuantum,toBeVisible,loggingOn,_fmiModelDescription.guid,derivatives);
    if (((BooleanToken)initFMUParameters.getToken()).booleanValue() && !_useRawJNI()) {
      _initializeFMUParameters();
    }
    _fmiInitializeJNI(timeValue);
    _fmiNewDiscreteStatesJNI(timeValue);
    _fmiEnterContinuousModeJNI(timeValue);
  }
  _createQSSSolver();
  _director.fireAtCurrentTime(this);
  return;
}

Fixed version (ground truth):
/** 
 * Initialize this FMU wrapper. <p>According to "System Design, Modeling, and Simulation Using Ptolemy II", version 1.02, section 12.3.1 "Execution Control": "The initialize action of the setup phase initializes parameters, resets local state, and sends out any initial messages."</p>
 * @exception IllegalActionException If the slave FMU cannot be initialized.
 */
public void initialize() throws IllegalActionException {
  if (_debugging) {
    _debug("String_Node_Str");
  }
  if (_initializables != null) {
    for (    Initializable initializable : _initializables) {
      initializable.initialize();
    }
  }
  if (_debugging) {
    _debugToStdOut(String.format("String_Node_Str",System.identityHashCode(this)));
  }
  int fmiFlag;
  _firstRound=true;
  _quantumScaleFactor=_director.getQuantumScaleFactor();
  _internalRelativeQuantum=_director.getRelativeQuantum() * _quantumScaleFactor;
  if (!_useRawJNI()) {
    if (((BooleanToken)initFMUParameters.getToken()).booleanValue() && !_useRawJNI()) {
      _initializeFMUParameters();
    }
    _fmiInitialize();
    _checkStateEvents();
    int newDiscreteStatesNeeded=1;
    int terminateSimulation=0;
    int nominalsOfContinuousStatesChanged=0;
    int valuesOfContinuousStatesChanged=0;
    int nextEventTimeDefined=0;
    double nextEventTime=0;
    _eventInfo=new FMI20EventInfo(newDiscreteStatesNeeded,terminateSimulation,nominalsOfContinuousStatesChanged,valuesOfContinuousStatesChanged,nextEventTimeDefined,nextEventTime);
    if (_fmiNewDiscreteStatesFunction == null) {
      throw new InternalErrorException(this,null,"String_Node_Str" + "String_Node_Str" + "String_Node_Str" + modelExchange + "String_Node_Str"+ _fmiModelDescription.modelExchange);
    }
    fmiFlag=((Integer)_fmiNewDiscreteStatesFunction.invoke(Integer.class,new Object[]{_fmiComponent,_eventInfo})).intValue();
    if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
      throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
    }
    if (_eventInfo.newDiscreteStatesNeeded != 0) {
      new Exception("String_Node_Str").printStackTrace();
    }
    if (_eventInfo.terminateSimulation != 0) {
      getDirector().finish();
    }
    fmiFlag=((Integer)_fmiEnterContinuousTimeModeFunction.invokeInt(new Object[]{_fmiComponent})).intValue();
    if (fmiFlag != FMILibrary.FMIStatus.fmiOK) {
      throw new IllegalActionException(this,"String_Node_Str" + _fmiStatusDescription(fmiFlag));
    }
  }
 else {
    final String modelIdentifier=_fmiModelDescription.modelIdentifier;
    byte toBeVisible=0;
    if (((BooleanToken)visible.getToken()).booleanValue()) {
      toBeVisible=1;
    }
    byte loggingOn=_debugging ? (byte)1 : (byte)0;
    String fmuLibPath=null;
    try {
      fmuLibPath=_fmiModelDescription.getNativeLibraryPath();
    }
 catch (    IOException ex) {
      throw new IllegalActionException(this,ex,"String_Node_Str");
    }
    final Time currentTime=_director.getModelTime();
    final Time startTime=_director.getModelStartTime();
    final Time stopTime=_director.getModelStopTime();
    final double timeValue=currentTime.getDoubleValue();
    double[] derivatives=new double[_fmiModelDescription.numberOfContinuousStates];
    _fmiComponentJNI=_fmiInstantiatesJNI(modelIdentifier,fmuLibPath,_fmiModelDescription.fmuResourceLocation,startTime.getDoubleValue(),stopTime.getDoubleValue(),timeValue,0,_internalRelativeQuantum,toBeVisible,loggingOn,_fmiModelDescription.guid,derivatives);
    if (((BooleanToken)initFMUParameters.getToken()).booleanValue() && !_useRawJNI()) {
      _initializeFMUParameters();
    }
    _fmiInitializeJNI(timeValue);
    _fmiNewDiscreteStatesJNI(timeValue);
    _fmiEnterContinuousModeJNI(timeValue);
  }
  _createQSSSolver();
  _director.fireAtCurrentTime(this);
  return;
}