Program: 51550
Project: 51550
Buggy source:
/** 
 * This method corresponds to the menu option File -> Compile. It does its work by calling compileLine().
 */
public synchronized void menuCompile(){
  threadRunning=true;
  interruptSent=false;
  noPauses=false;
  currentState=K91_COMPILING;
  setGUICommandsForCurrentState();
  CompileInfo compileinfo=null;
  int compilemode=currentSettings.getIntValue(Settings.COMPILE_MODE);
  int phase;
  boolean compilingCompleted=false;
  do {
    currentState=K91_COMPILING;
    setGUICommandsForCurrentState();
    try {
      compileinfo=control.compileLine();
    }
 catch (    TTK91CompileException e) {
      int errorLine=0;
      phase=CompileInfo.FIRST_ROUND;
      if (compileinfo != null) {
        errorLine=compileinfo.getLineNumber() + 1;
        phase=compileinfo.getPhase();
      }
      gui.addComment(errorLine + "String_Node_Str" + e.getMessage());
      gui.updateStatusBar(new Message("String_Node_Str").toString());
      if (phase == CompileInfo.FIRST_ROUND) {
        gui.selectLine(errorLine,GUI.CODE_TABLE);
      }
 else       if (phase == CompileInfo.SECOND_ROUND) {
        gui.selectLine(errorLine,GUI.INSTRUCTIONS_AND_DATA_TABLE);
      }
      currentState=K91_PAUSED;
      setGUICommandsForCurrentState();
      waitForContinueTask();
      break;
    }
    if (compileinfo == null) {
      compilingCompleted=true;
      break;
    }
 else {
      String comments=compileinfo.getComments();
      if (comments == null) {
        comments="String_Node_Str";
      }
      if ((compilemode & COMMENTED) != 0 && !comments.equals("String_Node_Str")) {
        gui.addComment(compileinfo.getLineNumber() + "String_Node_Str" + comments);
      }
      gui.updateStatusBar(comments);
      compilemode=currentSettings.getIntValue(Settings.COMPILE_MODE);
      phase=compileinfo.getPhase();
      if (phase == CompileInfo.FIRST_ROUND) {
        if (compileinfo.getSymbolFound()) {
          String symbolName=compileinfo.getSymbolName();
          Integer symbolValue=null;
          if (compileinfo.getSymbolDefined()) {
            symbolValue=new Integer(compileinfo.getSymbolValue());
          }
          gui.updateRowInSymbolTable(symbolName,symbolValue);
        }
        if (compileinfo.getLabelFound()) {
          String symbolName=compileinfo.getLabelName();
          Integer symbolValue=new Integer(compileinfo.getLabelValue());
          gui.updateRowInSymbolTable(symbolName,symbolValue);
        }
        gui.selectLine(compileinfo.getLineNumber(),GUI.CODE_TABLE);
      }
 else       if (phase == CompileInfo.FINALIZING_FIRST_ROUND) {
        String[][] symbolTable=compileinfo.getSymbolTable();
        if (symbolTable != null) {
          for (int i=0; i < symbolTable.length; i++) {
            String symbolName=symbolTable[i][0];
            Integer symbolValue=null;
            try {
              symbolValue=new Integer(symbolTable[i][1]);
            }
 catch (            NumberFormatException e) {
            }
            gui.updateRowInSymbolTable(symbolName,symbolValue);
          }
        }
        String[] newInstructionsContents=compileinfo.getInstructions();
        String[] newDataContents=compileinfo.getData();
        gui.insertToInstructionsTable(newInstructionsContents);
        gui.insertToDataTable(newDataContents);
        gui.setGUIView(3);
      }
 else       if (phase == CompileInfo.SECOND_ROUND) {
        int line=compileinfo.getLineNumber();
        int binary=compileinfo.getLineBinary();
        gui.updateInstructionsAndDataTableLine(line,binary);
        gui.selectLine(compileinfo.getLineNumber(),GUI.INSTRUCTIONS_AND_DATA_TABLE);
      }
      gui.repaint();
      if (((compilemode & PAUSED) != 0) && !comments.equals("String_Node_Str") && noPauses == false) {
        currentState=K91_PAUSED;
        setGUICommandsForCurrentState();
        waitForContinueTask();
      }
 else {
        try {
          wait(SLOWDOWN + 1);
        }
 catch (        InterruptedException e) {
          System.out.println("String_Node_Str");
        }
      }
    }
  }
 while (interruptSent == false);
  if (currentState == INTERRUPTED_WITH_PAUSE) {
    setGUICommandsForCurrentState();
    waitForContinueTask();
  }
  if (compilingCompleted == true) {
    try {
      control.saveBinary();
      System.out.println(new Message("String_Node_Str").toString());
    }
 catch (    IOException e) {
      System.out.println(e);
    }
    gui.resetAll();
    gui.addComment("String_Node_Str");
    gui.addComment(new Message("String_Node_Str").toString());
    gui.addComment("String_Node_Str");
    loadAndUpdateGUI();
  }
 else {
    try {
      control.openSource(currentlyOpenedFile);
    }
 catch (    IOException e) {
      gui.showError(e.getMessage());
      currentState=NONE;
      setGUICommandsForCurrentState();
      return;
    }
    currentState=K91_NOT_COMPILING;
    setGUICommandsForCurrentState();
    gui.setGUIView(2);
    gui.resetAll();
    gui.addComment("String_Node_Str");
    gui.addComment(new Message("String_Node_Str").toString());
    gui.addComment("String_Node_Str");
    continueTask();
  }
  threadRunning=false;
  continueTask();
}

Fixed version (ground truth):
/** 
 * This method corresponds to the menu option File -> Compile. It does its work by calling compileLine().
 */
public void menuCompile(){
synchronized (lock) {
    threadRunning=true;
    interruptSent=false;
    noPauses=false;
    currentState=K91_COMPILING;
    setGUICommandsForCurrentState();
    CompileInfo compileinfo=null;
    int compilemode=currentSettings.getIntValue(Settings.COMPILE_MODE);
    int phase;
    boolean compilingCompleted=false;
    do {
      currentState=K91_COMPILING;
      setGUICommandsForCurrentState();
      try {
        compileinfo=control.compileLine();
      }
 catch (      TTK91CompileException e) {
        int errorLine=0;
        phase=CompileInfo.FIRST_ROUND;
        if (compileinfo != null) {
          errorLine=compileinfo.getLineNumber() + 1;
          phase=compileinfo.getPhase();
        }
        gui.addComment(errorLine + "String_Node_Str" + e.getMessage());
        gui.updateStatusBar(new Message("String_Node_Str").toString());
        if (phase == CompileInfo.FIRST_ROUND) {
          gui.selectLine(errorLine,GUI.CODE_TABLE);
        }
 else         if (phase == CompileInfo.SECOND_ROUND) {
          gui.selectLine(errorLine,GUI.INSTRUCTIONS_AND_DATA_TABLE);
        }
        currentState=K91_PAUSED;
        setGUICommandsForCurrentState();
        waitForContinueTask();
        break;
      }
      if (compileinfo == null) {
        compilingCompleted=true;
        break;
      }
 else {
        String comments=compileinfo.getComments();
        if (comments == null) {
          comments="String_Node_Str";
        }
        if ((compilemode & COMMENTED) != 0 && !comments.equals("String_Node_Str")) {
          gui.addComment(compileinfo.getLineNumber() + "String_Node_Str" + comments);
        }
        gui.updateStatusBar(comments);
        compilemode=currentSettings.getIntValue(Settings.COMPILE_MODE);
        phase=compileinfo.getPhase();
        if (phase == CompileInfo.FIRST_ROUND) {
          if (compileinfo.getSymbolFound()) {
            String symbolName=compileinfo.getSymbolName();
            Integer symbolValue=null;
            if (compileinfo.getSymbolDefined()) {
              symbolValue=new Integer(compileinfo.getSymbolValue());
            }
            gui.updateRowInSymbolTable(symbolName,symbolValue);
          }
          if (compileinfo.getLabelFound()) {
            String symbolName=compileinfo.getLabelName();
            Integer symbolValue=new Integer(compileinfo.getLabelValue());
            gui.updateRowInSymbolTable(symbolName,symbolValue);
          }
          gui.selectLine(compileinfo.getLineNumber(),GUI.CODE_TABLE);
        }
 else         if (phase == CompileInfo.FINALIZING_FIRST_ROUND) {
          String[][] symbolTable=compileinfo.getSymbolTable();
          if (symbolTable != null) {
            for (int i=0; i < symbolTable.length; i++) {
              String symbolName=symbolTable[i][0];
              Integer symbolValue=null;
              try {
                symbolValue=new Integer(symbolTable[i][1]);
              }
 catch (              NumberFormatException e) {
              }
              gui.updateRowInSymbolTable(symbolName,symbolValue);
            }
          }
          String[] newInstructionsContents=compileinfo.getInstructions();
          String[] newDataContents=compileinfo.getData();
          gui.insertToInstructionsTable(newInstructionsContents);
          gui.insertToDataTable(newDataContents);
          gui.setGUIView(3);
        }
 else         if (phase == CompileInfo.SECOND_ROUND) {
          int line=compileinfo.getLineNumber();
          int binary=compileinfo.getLineBinary();
          gui.updateInstructionsAndDataTableLine(line,binary);
          gui.selectLine(compileinfo.getLineNumber(),GUI.INSTRUCTIONS_AND_DATA_TABLE);
        }
        gui.repaint();
        if (((compilemode & PAUSED) != 0) && !comments.equals("String_Node_Str") && noPauses == false) {
          currentState=K91_PAUSED;
          setGUICommandsForCurrentState();
          waitForContinueTask();
        }
 else {
          try {
            lock.wait(SLOWDOWN + 1);
          }
 catch (          InterruptedException e) {
            System.out.println("String_Node_Str");
          }
        }
      }
    }
 while (interruptSent == false);
    if (currentState == INTERRUPTED_WITH_PAUSE) {
      setGUICommandsForCurrentState();
      waitForContinueTask();
    }
    if (compilingCompleted == true) {
      try {
        control.saveBinary();
        System.out.println(new Message("String_Node_Str").toString());
      }
 catch (      IOException e) {
        System.out.println(e);
      }
      gui.resetAll();
      gui.addComment("String_Node_Str");
      gui.addComment(new Message("String_Node_Str").toString());
      gui.addComment("String_Node_Str");
      loadAndUpdateGUI();
    }
 else {
      try {
        control.openSource(currentlyOpenedFile);
      }
 catch (      IOException e) {
        gui.showError(e.getMessage());
        currentState=NONE;
        setGUICommandsForCurrentState();
        return;
      }
      currentState=K91_NOT_COMPILING;
      setGUICommandsForCurrentState();
      gui.setGUIView(2);
      gui.resetAll();
      gui.addComment("String_Node_Str");
      gui.addComment(new Message("String_Node_Str").toString());
      gui.addComment("String_Node_Str");
      continueTask();
    }
    threadRunning=false;
    continueTask();
  }
}