Program: 74477
Project: 74477
Buggy source:
/** 
 * Generate code.  This is the main entry point.
 * @param code The code buffer into which to generate the code.
 * @return The return value of the last subprocess that was executed.or -1 if no commands were executed.
 * @exception KernelException If a type conflict occurs or the modelis running.
 */
public StringBuffer generateCode(String modelType,String inputTemporalFormula,String formulaType,String variableSpanSize,String outputChoice,String FSMBufferSize) throws Exception {
  StringBuffer returnStringBuffer=new StringBuffer("String_Node_Str");
  _codeFile=null;
  if (_model instanceof Actor) {
    if (_model instanceof CompositeActor) {
      if (REDUtility.isValidModelForVerification((CompositeActor)_model) || SMVUtility.isValidModelForVerification((CompositeActor)_model)) {
        StringBuffer systemDescription=new StringBuffer("String_Node_Str");
        if (modelType.equalsIgnoreCase("String_Node_Str")) {
          systemDescription.append(SMVUtility.advancedGenerateSMVDescription((CompositeActor)_model,inputTemporalFormula,formulaType,variableSpanSize));
          if (outputChoice.equalsIgnoreCase("String_Node_Str")) {
            JFileChooser fileSaveDialog=new JFileChooser();
            fileSaveDialog.setDialogType(JFileChooser.SAVE_DIALOG);
            fileSaveDialog.setDialogTitle("String_Node_Str");
            if (_directory != null) {
              fileSaveDialog.setCurrentDirectory(_directory);
            }
 else {
              String cwd=StringUtilities.getProperty("String_Node_Str");
              if (cwd != null) {
                fileSaveDialog.setCurrentDirectory(new File(cwd));
              }
            }
            int returnValue=fileSaveDialog.showSaveDialog(null);
            if (returnValue == JFileChooser.APPROVE_OPTION) {
              _directory=fileSaveDialog.getCurrentDirectory();
              FileWriter smvFileWriter=null;
              try {
                File smvFile=fileSaveDialog.getSelectedFile().getCanonicalFile();
                if (smvFile.exists()) {
                  String queryString="String_Node_Str" + smvFile.getName() + "String_Node_Str";
                  int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
                  if (selected == 0) {
                    smvFileWriter=new FileWriter(smvFile);
                    smvFileWriter.write(systemDescription.toString());
                    _codeFile=smvFile;
                  }
                }
 else {
                  smvFileWriter=new FileWriter(smvFile);
                  smvFileWriter.write(systemDescription.toString());
                  _codeFile=smvFile;
                }
              }
  finally {
                if (smvFileWriter != null) {
                  smvFileWriter.close();
                }
              }
            }
          }
 else {
            Random rd=new Random();
            String folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
            File smvFolder=new File(folderName);
            if (smvFolder.exists()) {
              while (smvFolder.exists() == true) {
                folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
                smvFolder=new File(folderName);
              }
              boolean isOpened=smvFolder.mkdir();
              if (isOpened == false) {
                MessageHandler.warning("String_Node_Str");
              }
            }
 else {
              boolean isOpened=smvFolder.mkdir();
              if (isOpened == false) {
                MessageHandler.warning("String_Node_Str");
              }
            }
            File smvFile=new File(folderName + "String_Node_Str");
            FileWriter smvFileWriter=null;
            String fileAbsolutePath=smvFile.getAbsolutePath();
            try {
              smvFileWriter=new FileWriter(smvFile);
              smvFileWriter.write(systemDescription.toString());
            }
  finally {
              if (smvFileWriter != null) {
                smvFileWriter.close();
              }
            }
            StringBuffer str=new StringBuffer("String_Node_Str");
            try {
              Runtime rt=Runtime.getRuntime();
              Process pr=rt.exec("String_Node_Str" + "String_Node_Str" + fileAbsolutePath + "String_Node_Str");
              InputStreamReader inputStream=new InputStreamReader(pr.getInputStream());
              BufferedReader reader=new BufferedReader(inputStream);
              String line=null;
              while ((line=reader.readLine()) != null) {
                str.append(line + "String_Node_Str");
              }
              reader.close();
            }
 catch (            Exception ex) {
              MessageHandler.warning("String_Node_Str" + ex);
            }
            returnStringBuffer.append(str);
            _deleteFolder(smvFolder);
            return returnStringBuffer;
          }
        }
 else {
          systemDescription.append(REDUtility.generateREDDescription((CompositeActor)_model,inputTemporalFormula,formulaType,variableSpanSize,FSMBufferSize));
          if (outputChoice.equalsIgnoreCase("String_Node_Str")) {
            JFileChooser fileSaveDialog=new JFileChooser();
            fileSaveDialog.setDialogType(JFileChooser.SAVE_DIALOG);
            fileSaveDialog.setDialogTitle("String_Node_Str");
            if (_directory != null) {
              fileSaveDialog.setCurrentDirectory(_directory);
            }
 else {
              String cwd=StringUtilities.getProperty("String_Node_Str");
              if (cwd != null) {
                fileSaveDialog.setCurrentDirectory(new File(cwd));
              }
            }
            int returnValue=fileSaveDialog.showSaveDialog(null);
            if (returnValue == JFileChooser.APPROVE_OPTION) {
              _directory=fileSaveDialog.getCurrentDirectory();
              FileWriter smvFileWriter=null;
              try {
                File smvFile=fileSaveDialog.getSelectedFile().getCanonicalFile();
                if (smvFile.exists()) {
                  String queryString="String_Node_Str" + smvFile.getName() + "String_Node_Str";
                  int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
                  if (selected == 0) {
                    smvFileWriter=new FileWriter(smvFile);
                    smvFileWriter.write(systemDescription.toString());
                    _codeFile=smvFile;
                  }
                }
 else {
                  smvFileWriter=new FileWriter(smvFile);
                  smvFileWriter.write(systemDescription.toString());
                  _codeFile=smvFile;
                }
              }
  finally {
                if (smvFileWriter != null) {
                  smvFileWriter.close();
                }
              }
            }
          }
 else {
            MessageHandler.error("String_Node_Str");
          }
        }
      }
 else {
        MessageHandler.error("String_Node_Str");
      }
    }
 else     if (_model instanceof FSMActor) {
      Query query=new Query();
      query.addLine("String_Node_Str","String_Node_Str","String_Node_Str");
      String[] possibleFormulaChoice=new String[2];
      possibleFormulaChoice[0]="String_Node_Str";
      possibleFormulaChoice[1]="String_Node_Str";
      query.addRadioButtons("String_Node_Str","String_Node_Str",possibleFormulaChoice,"String_Node_Str");
      query.addLine("String_Node_Str","String_Node_Str","String_Node_Str");
      String[] possibleOutputChoice=new String[3];
      possibleOutputChoice[0]="String_Node_Str";
      possibleOutputChoice[1]="String_Node_Str";
      possibleOutputChoice[2]="String_Node_Str";
      query.addRadioButtons("String_Node_Str","String_Node_Str",possibleOutputChoice,"String_Node_Str");
      ComponentDialog dialog=new ComponentDialog(null,"String_Node_Str",query);
      String pattern="String_Node_Str";
      String finalChoice="String_Node_Str";
      String span="String_Node_Str";
      if (dialog.buttonPressed().equals("String_Node_Str")) {
        pattern=query.getStringValue("String_Node_Str");
        finalChoice=query.getStringValue("String_Node_Str");
        span=query.getStringValue("String_Node_Str");
        FmvAutomaton model=(FmvAutomaton)_model;
        StringBuffer fmvFormat=new StringBuffer("String_Node_Str");
        FileWriter smvFileWriter=null;
        if (query.getStringValue("String_Node_Str").equalsIgnoreCase("String_Node_Str")) {
          fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
          JFileChooser fileSaveDialog=new JFileChooser();
          fileSaveDialog.setDialogType(JFileChooser.SAVE_DIALOG);
          fileSaveDialog.setDialogTitle("String_Node_Str");
          if (_directory != null) {
            fileSaveDialog.setCurrentDirectory(_directory);
          }
 else {
            String cwd=StringUtilities.getProperty("String_Node_Str");
            if (cwd != null) {
              fileSaveDialog.setCurrentDirectory(new File(cwd));
            }
          }
          int returnValue=fileSaveDialog.showOpenDialog(null);
          if (returnValue == JFileChooser.APPROVE_OPTION) {
            _directory=fileSaveDialog.getCurrentDirectory();
            File smvFile=fileSaveDialog.getSelectedFile().getCanonicalFile();
            if (smvFile.exists()) {
              String queryString="String_Node_Str" + smvFile.getName() + "String_Node_Str";
              int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
              if (selected == 0) {
                smvFileWriter=new FileWriter(smvFile);
                smvFileWriter.write(fmvFormat.toString());
                _codeFile=smvFile;
              }
            }
 else {
              smvFileWriter=new FileWriter(smvFile);
              smvFileWriter.write(fmvFormat.toString());
              _codeFile=smvFile;
            }
          }
          try {
            if (smvFileWriter != null)             smvFileWriter.close();
          }
 catch (          Exception ex) {
            MessageHandler.error("String_Node_Str" + ex.getMessage());
          }
        }
 else         if (query.getStringValue("String_Node_Str").equalsIgnoreCase("String_Node_Str")) {
          try {
            fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
            Query newQuery=new Query();
            newQuery.setTextWidth(90);
            newQuery.addTextArea("String_Node_Str",_model.getName(),fmvFormat.toString());
            ComponentDialog newDialog=new ComponentDialog(null,"String_Node_Str",newQuery);
          }
 catch (          Exception ex) {
            MessageHandler.error("String_Node_Str" + ex.getMessage());
          }
        }
 else {
          fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
          Random rd=new Random();
          String folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
          File smvFolder=new File(folderName);
          if (smvFolder.exists()) {
            while (smvFolder.exists() == true) {
              folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
              smvFolder=new File(folderName);
            }
            smvFolder.mkdir();
            System.out.println(smvFolder.getAbsolutePath());
          }
 else {
            smvFolder.mkdir();
            System.out.println(smvFolder.getAbsolutePath());
          }
          File smvFile=new File(folderName + "String_Node_Str");
          String fileAbsolutePath=smvFile.getAbsolutePath();
          try {
            smvFileWriter=new FileWriter(smvFile);
            smvFileWriter.write(fmvFormat.toString());
          }
  finally {
            if (smvFileWriter != null) {
              smvFileWriter.close();
            }
          }
          StringBuffer str=new StringBuffer("String_Node_Str");
          try {
            Runtime rt=Runtime.getRuntime();
            Process pr=rt.exec("String_Node_Str" + "String_Node_Str" + fileAbsolutePath + "String_Node_Str");
            InputStreamReader inputStream=new InputStreamReader(pr.getInputStream());
            BufferedReader reader=new BufferedReader(inputStream);
            String line=null;
            while ((line=reader.readLine()) != null) {
              str.append(line + "String_Node_Str");
            }
            reader.close();
          }
 catch (          Exception ex) {
            MessageHandler.warning("String_Node_Str" + ex.getMessage());
          }
          Query newQuery=new Query();
          newQuery.setTextWidth(80);
          newQuery.addTextArea("String_Node_Str","String_Node_Str",str.toString());
          ComponentDialog newDialog=new ComponentDialog(null,"String_Node_Str",newQuery);
          _deleteFolder(smvFolder);
        }
      }
    }
  }
  return returnStringBuffer;
}

Fixed version (ground truth):
/** 
 * Generate code.  This is the main entry point.
 * @param code The code buffer into which to generate the code.
 * @return The return value of the last subprocess that was executed.or -1 if no commands were executed.
 * @exception KernelException If a type conflict occurs or the modelis running.
 */
public StringBuffer generateCode(String modelType,String inputTemporalFormula,String formulaType,String variableSpanSize,String outputChoice,String FSMBufferSize) throws Exception {
  StringBuffer returnStringBuffer=new StringBuffer("String_Node_Str");
  _codeFile=null;
  if (_model instanceof Actor) {
    if (_model instanceof CompositeActor) {
      if (REDUtility.isValidModelForVerification((CompositeActor)_model) || SMVUtility.isValidModelForVerification((CompositeActor)_model)) {
        StringBuffer systemDescription=new StringBuffer("String_Node_Str");
        if (modelType.equalsIgnoreCase("String_Node_Str")) {
          systemDescription.append(SMVUtility.advancedGenerateSMVDescription((CompositeActor)_model,inputTemporalFormula,formulaType,variableSpanSize));
          if (outputChoice.equalsIgnoreCase("String_Node_Str")) {
            JFileChooser fileSaveDialog=new JFileChooser();
            fileSaveDialog.setDialogType(JFileChooser.SAVE_DIALOG);
            fileSaveDialog.setDialogTitle("String_Node_Str");
            if (_directory != null) {
              fileSaveDialog.setCurrentDirectory(_directory);
            }
 else {
              String cwd=StringUtilities.getProperty("String_Node_Str");
              if (cwd != null) {
                fileSaveDialog.setCurrentDirectory(new File(cwd));
              }
            }
            int returnValue=fileSaveDialog.showSaveDialog(null);
            if (returnValue == JFileChooser.APPROVE_OPTION) {
              _directory=fileSaveDialog.getCurrentDirectory();
              FileWriter smvFileWriter=null;
              try {
                File smvFile=fileSaveDialog.getSelectedFile().getCanonicalFile();
                if (smvFile.exists()) {
                  String queryString="String_Node_Str" + smvFile.getName() + "String_Node_Str";
                  int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
                  if (selected == 0) {
                    smvFileWriter=new FileWriter(smvFile);
                    smvFileWriter.write(systemDescription.toString());
                    _codeFile=smvFile;
                  }
                }
 else {
                  smvFileWriter=new FileWriter(smvFile);
                  smvFileWriter.write(systemDescription.toString());
                  _codeFile=smvFile;
                }
              }
  finally {
                if (smvFileWriter != null) {
                  smvFileWriter.close();
                }
              }
            }
          }
 else {
            Random rd=new Random();
            String folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
            File smvFolder=new File(folderName);
            if (smvFolder.exists()) {
              while (smvFolder.exists() == true) {
                folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
                smvFolder=new File(folderName);
              }
              boolean isOpened=smvFolder.mkdir();
              if (isOpened == false) {
                MessageHandler.warning("String_Node_Str");
              }
            }
 else {
              boolean isOpened=smvFolder.mkdir();
              if (isOpened == false) {
                MessageHandler.warning("String_Node_Str");
              }
            }
            File smvFile=new File(folderName + "String_Node_Str");
            FileWriter smvFileWriter=null;
            String fileAbsolutePath=smvFile.getAbsolutePath();
            try {
              smvFileWriter=new FileWriter(smvFile);
              smvFileWriter.write(systemDescription.toString());
            }
  finally {
              if (smvFileWriter != null) {
                smvFileWriter.close();
              }
            }
            StringBuffer str=new StringBuffer("String_Node_Str");
            try {
              Runtime rt=Runtime.getRuntime();
              Process pr=rt.exec("String_Node_Str" + "String_Node_Str" + fileAbsolutePath + "String_Node_Str");
              InputStreamReader inputStream=new InputStreamReader(pr.getInputStream());
              BufferedReader reader=new BufferedReader(inputStream);
              String line=null;
              while ((line=reader.readLine()) != null) {
                str.append(line + "String_Node_Str");
              }
              reader.close();
            }
 catch (            Exception ex) {
              MessageHandler.warning("String_Node_Str" + ex);
            }
            returnStringBuffer.append(str);
            _deleteFolder(smvFolder);
            return returnStringBuffer;
          }
        }
 else {
          systemDescription.append(REDUtility.generateREDDescription((CompositeActor)_model,inputTemporalFormula,formulaType,variableSpanSize,FSMBufferSize));
          if (outputChoice.equalsIgnoreCase("String_Node_Str")) {
            JFileChooser fileSaveDialog=new JFileChooser();
            fileSaveDialog.setDialogType(JFileChooser.SAVE_DIALOG);
            fileSaveDialog.setDialogTitle("String_Node_Str");
            if (_directory != null) {
              fileSaveDialog.setCurrentDirectory(_directory);
            }
 else {
              String cwd=StringUtilities.getProperty("String_Node_Str");
              if (cwd != null) {
                fileSaveDialog.setCurrentDirectory(new File(cwd));
              }
            }
            int returnValue=fileSaveDialog.showSaveDialog(null);
            if (returnValue == JFileChooser.APPROVE_OPTION) {
              _directory=fileSaveDialog.getCurrentDirectory();
              FileWriter smvFileWriter=null;
              try {
                File smvFile=fileSaveDialog.getSelectedFile().getCanonicalFile();
                if (smvFile.exists()) {
                  String queryString="String_Node_Str" + smvFile.getName() + "String_Node_Str";
                  int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
                  if (selected == 0) {
                    smvFileWriter=new FileWriter(smvFile);
                    smvFileWriter.write(systemDescription.toString());
                    _codeFile=smvFile;
                  }
                }
 else {
                  smvFileWriter=new FileWriter(smvFile);
                  smvFileWriter.write(systemDescription.toString());
                  _codeFile=smvFile;
                }
              }
  finally {
                if (smvFileWriter != null) {
                  smvFileWriter.close();
                }
              }
            }
          }
 else {
            MessageHandler.error("String_Node_Str");
          }
        }
      }
 else {
        MessageHandler.error("String_Node_Str");
      }
    }
 else     if (_model instanceof FSMActor) {
      Query query=new Query();
      query.addLine("String_Node_Str","String_Node_Str","String_Node_Str");
      String[] possibleFormulaChoice=new String[2];
      possibleFormulaChoice[0]="String_Node_Str";
      possibleFormulaChoice[1]="String_Node_Str";
      query.addRadioButtons("String_Node_Str","String_Node_Str",possibleFormulaChoice,"String_Node_Str");
      query.addLine("String_Node_Str","String_Node_Str","String_Node_Str");
      String[] possibleOutputChoice=new String[3];
      possibleOutputChoice[0]="String_Node_Str";
      possibleOutputChoice[1]="String_Node_Str";
      possibleOutputChoice[2]="String_Node_Str";
      query.addRadioButtons("String_Node_Str","String_Node_Str",possibleOutputChoice,"String_Node_Str");
      ComponentDialog dialog=new ComponentDialog(null,"String_Node_Str",query);
      String pattern="String_Node_Str";
      String finalChoice="String_Node_Str";
      String span="String_Node_Str";
      if (dialog.buttonPressed().equals("String_Node_Str")) {
        pattern=query.getStringValue("String_Node_Str");
        finalChoice=query.getStringValue("String_Node_Str");
        span=query.getStringValue("String_Node_Str");
        FmvAutomaton model=(FmvAutomaton)_model;
        StringBuffer fmvFormat=new StringBuffer("String_Node_Str");
        FileWriter smvFileWriter=null;
        if (query.getStringValue("String_Node_Str").equalsIgnoreCase("String_Node_Str")) {
          fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
          JFileChooser fileSaveDialog=new JFileChooser();
          fileSaveDialog.setDialogType(JFileChooser.SAVE_DIALOG);
          fileSaveDialog.setDialogTitle("String_Node_Str");
          if (_directory != null) {
            fileSaveDialog.setCurrentDirectory(_directory);
          }
 else {
            String cwd=StringUtilities.getProperty("String_Node_Str");
            if (cwd != null) {
              fileSaveDialog.setCurrentDirectory(new File(cwd));
            }
          }
          int returnValue=fileSaveDialog.showOpenDialog(null);
          try {
            if (returnValue == JFileChooser.APPROVE_OPTION) {
              _directory=fileSaveDialog.getCurrentDirectory();
              File smvFile=fileSaveDialog.getSelectedFile().getCanonicalFile();
              if (smvFile.exists()) {
                String queryString="String_Node_Str" + smvFile.getName() + "String_Node_Str";
                int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
                if (selected == 0) {
                  smvFileWriter=new FileWriter(smvFile);
                  smvFileWriter.write(fmvFormat.toString());
                  _codeFile=smvFile;
                }
              }
 else {
                smvFileWriter=new FileWriter(smvFile);
                smvFileWriter.write(fmvFormat.toString());
                _codeFile=smvFile;
              }
            }
            if (smvFileWriter != null)             smvFileWriter.close();
          }
 catch (          Exception ex) {
            MessageHandler.error("String_Node_Str" + ex.getMessage());
          }
        }
 else         if (query.getStringValue("String_Node_Str").equalsIgnoreCase("String_Node_Str")) {
          try {
            fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
            Query newQuery=new Query();
            newQuery.setTextWidth(90);
            newQuery.addTextArea("String_Node_Str",_model.getName(),fmvFormat.toString());
            ComponentDialog newDialog=new ComponentDialog(null,"String_Node_Str",newQuery);
          }
 catch (          Exception ex) {
            MessageHandler.error("String_Node_Str" + ex.getMessage());
          }
        }
 else {
          fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
          Random rd=new Random();
          String folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
          File smvFolder=new File(folderName);
          if (smvFolder.exists()) {
            while (smvFolder.exists() == true) {
              folderName="String_Node_Str" + Integer.toString(rd.nextInt(10000)) + "String_Node_Str";
              smvFolder=new File(folderName);
            }
            boolean isOpened=smvFolder.mkdir();
            if (isOpened == false) {
              MessageHandler.warning("String_Node_Str");
            }
          }
 else {
            boolean isOpened=smvFolder.mkdir();
            if (isOpened == false) {
              MessageHandler.warning("String_Node_Str");
            }
          }
          File smvFile=new File(folderName + "String_Node_Str");
          String fileAbsolutePath=smvFile.getAbsolutePath();
          try {
            smvFileWriter=new FileWriter(smvFile);
            smvFileWriter.write(fmvFormat.toString());
          }
  finally {
            if (smvFileWriter != null) {
              smvFileWriter.close();
            }
          }
          StringBuffer str=new StringBuffer("String_Node_Str");
          try {
            Runtime rt=Runtime.getRuntime();
            Process pr=rt.exec("String_Node_Str" + "String_Node_Str" + fileAbsolutePath + "String_Node_Str");
            InputStreamReader inputStream=new InputStreamReader(pr.getInputStream());
            BufferedReader reader=new BufferedReader(inputStream);
            String line=null;
            while ((line=reader.readLine()) != null) {
              str.append(line + "String_Node_Str");
            }
            reader.close();
          }
 catch (          Exception ex) {
            MessageHandler.warning("String_Node_Str" + ex.getMessage());
          }
          returnStringBuffer.append(str);
          _deleteFolder(smvFolder);
          return returnStringBuffer;
        }
      }
    }
  }
  return returnStringBuffer;
}