Program: 74501
Project: 74501
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 int generateCode() throws Exception {
  if (_model instanceof Actor) {
    if (_model instanceof CompositeActor) {
      if (SMVUtility.isValidModelForVerification((CompositeActor)_model)) {
        StringBuffer smvDescritpion=new StringBuffer("String_Node_Str");
        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 finalFormulaChoice="String_Node_Str";
        String finalOutputChoice="String_Node_Str";
        String span="String_Node_Str";
        if (dialog.buttonPressed().equals("String_Node_Str")) {
          pattern=query.getStringValue("String_Node_Str");
          finalFormulaChoice=query.getStringValue("String_Node_Str");
          span=query.getStringValue("String_Node_Str");
          smvDescritpion.append(SMVUtility.generateSMVDescription((CompositeActor)_model,pattern,finalFormulaChoice,span));
          if (query.getStringValue("String_Node_Str").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(smvDescritpion.toString());
                  }
                }
              }
  finally {
                if (smvFileWriter != null) {
                  smvFileWriter.close();
                }
              }
            }
          }
 else           if (query.getStringValue("String_Node_Str").equalsIgnoreCase("String_Node_Str")) {
          }
 else {
          }
        }
      }
 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;
        try {
          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());
              }
            }
          }
        }
 catch (        Exception ex) {
          MessageHandler.error("String_Node_Str" + ex.getMessage());
        }
        try {
          if (smvFileWriter != null)           smvFileWriter.close();
        }
 catch (        Exception ex) {
          MessageHandler.error("String_Node_Str" + ex.getMessage());
        }
      }
    }
  }
  return 0;
}

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 int generateCode() throws Exception {
  if (_model instanceof Actor) {
    if (_model instanceof CompositeActor) {
      if (SMVUtility.isValidModelForVerification((CompositeActor)_model)) {
        StringBuffer smvDescritpion=new StringBuffer("String_Node_Str");
        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 finalFormulaChoice="String_Node_Str";
        String finalOutputChoice="String_Node_Str";
        String span="String_Node_Str";
        if (dialog.buttonPressed().equals("String_Node_Str")) {
          pattern=query.getStringValue("String_Node_Str");
          finalFormulaChoice=query.getStringValue("String_Node_Str");
          span=query.getStringValue("String_Node_Str");
          smvDescritpion.append(SMVUtility.generateSMVDescription((CompositeActor)_model,pattern,finalFormulaChoice,span));
          if (query.getStringValue("String_Node_Str").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(smvDescritpion.toString());
                  }
                }
 else {
                  smvFileWriter=new FileWriter(smvFile);
                  smvFileWriter.write(smvDescritpion.toString());
                }
              }
  finally {
                if (smvFileWriter != null) {
                  smvFileWriter.close();
                }
              }
            }
          }
 else           if (query.getStringValue("String_Node_Str").equalsIgnoreCase("String_Node_Str")) {
          }
 else {
            String folderName="String_Node_Str" + Integer.toString(((int)(Math.random() * 10000))) + "String_Node_Str";
            File smvFolder=new File(folderName);
            if (smvFolder.exists()) {
              while (smvFolder.exists() == true) {
                folderName="String_Node_Str" + Integer.toString(((int)(Math.random() * 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");
            FileWriter smvFileWriter=null;
            String fileAbsolutePath=smvFile.getAbsolutePath();
            try {
              smvFileWriter=new FileWriter(smvFile);
              smvFileWriter.write(smvDescritpion.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);
            }
            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);
          }
        }
      }
 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")) {
          try {
            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());
                }
              }
 else {
                smvFileWriter=new FileWriter(smvFile);
                smvFileWriter.write(fmvFormat.toString());
              }
            }
          }
 catch (          Exception ex) {
            MessageHandler.error("String_Node_Str" + ex.getMessage());
          }
          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")) {
        }
 else {
          try {
            fmvFormat.append(model.convertToSMVFormat(pattern,finalChoice,span));
            String folderName="String_Node_Str" + Integer.toString(((int)(Math.random() * 10000))) + "String_Node_Str";
            File smvFolder=new File(folderName);
            if (smvFolder.exists()) {
              while (smvFolder.exists() == true) {
                folderName="String_Node_Str" + Integer.toString(((int)(Math.random() * 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);
            }
            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);
          }
 catch (          Exception ex) {
            MessageHandler.error("String_Node_Str" + ex.getMessage());
          }
        }
      }
    }
  }
  return 0;
}