Program: 9207
Project: 9207
Buggy source:
/** 
 * @throws AbortException if check for runtime fails 
 */
protected boolean doBuild(AjBuildConfig buildConfig,IMessageHandler baseHandler,boolean batch) throws IOException, AbortException {
  boolean ret=true;
  batchCompile=batch;
  wasFullBuild=batch;
  if (baseHandler instanceof ILifecycleAware) {
    ((ILifecycleAware)baseHandler).buildStarting(!batch);
  }
  CompilationAndWeavingContext.reset();
  int phase=batch ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD;
  ContextToken ct=CompilationAndWeavingContext.enteringPhase(phase,buildConfig);
  try {
    if (batch) {
      this.state=new AjState(this);
    }
    this.state.setCouldBeSubsequentIncrementalBuild(this.environmentSupportsIncrementalCompilation);
    boolean canIncremental=state.prepareForNextBuild(buildConfig);
    if (!canIncremental && !batch) {
      CompilationAndWeavingContext.leavingPhase(ct);
      if (state.listenerDefined())       state.getListener().recordDecision("String_Node_Str");
      return doBuild(buildConfig,baseHandler,true);
    }
    this.handler=CountingMessageHandler.makeCountingMessageHandler(baseHandler);
    if (buildConfig == null || buildConfig.isCheckRuntimeVersion()) {
      if (DO_RUNTIME_VERSION_CHECK) {
        String check=checkRtJar(buildConfig);
        if (check != null) {
          if (FAIL_IF_RUNTIME_NOT_FOUND) {
            MessageUtil.error(handler,check);
            CompilationAndWeavingContext.leavingPhase(ct);
            return false;
          }
 else {
            MessageUtil.warn(handler,check);
          }
        }
      }
    }
    setBuildConfig(buildConfig);
    if (batch || !AsmManager.attemptIncrementalModelRepairs) {
      setupModel(buildConfig);
    }
    if (batch) {
      initBcelWorld(handler);
    }
    if (handler.hasErrors()) {
      CompilationAndWeavingContext.leavingPhase(ct);
      return false;
    }
    if (buildConfig.getOutputJar() != null) {
      if (!openOutputStream(buildConfig.getOutputJar())) {
        CompilationAndWeavingContext.leavingPhase(ct);
        return false;
      }
    }
    if (batch) {
      if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
        getWorld().setModel(AsmManager.getDefault().getHierarchy());
      }
      binarySourcesForTheNextCompile=state.getBinaryFilesToCompile(true);
      performCompilation(buildConfig.getFiles());
      state.clearBinarySourceFiles();
      if (!continueWhenErrors && handler.hasErrors()) {
        CompilationAndWeavingContext.leavingPhase(ct);
        if (AsmManager.isReporting())         AsmManager.getDefault().reportModelInfo("String_Node_Str");
        return false;
      }
      if (AsmManager.isReporting())       AsmManager.getDefault().reportModelInfo("String_Node_Str");
    }
 else {
      binarySourcesForTheNextCompile=state.getBinaryFilesToCompile(true);
      Set files=state.getFilesToCompile(true);
      if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode())       if (AsmManager.attemptIncrementalModelRepairs)       AsmManager.getDefault().processDelta(files,state.getAddedFiles(),state.getDeletedFiles());
      boolean hereWeGoAgain=!(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty());
      for (int i=0; (i < 5) && hereWeGoAgain; i++) {
        if (state.listenerDefined())         state.getListener().recordInformation("String_Node_Str" + (i + 1) + "String_Node_Str");
        performCompilation(files);
        if ((!continueWhenErrors && handler.hasErrors()) || (progressListener != null && progressListener.isCancelledRequested())) {
          CompilationAndWeavingContext.leavingPhase(ct);
          return false;
        }
        if (state.requiresFullBatchBuild()) {
          if (state.listenerDefined())           state.getListener().recordInformation("String_Node_Str");
          return batchBuild(buildConfig,baseHandler);
        }
        binarySourcesForTheNextCompile=state.getBinaryFilesToCompile(false);
        files=state.getFilesToCompile(false);
        hereWeGoAgain=!(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty());
        if (hereWeGoAgain) {
          if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode())           if (AsmManager.attemptIncrementalModelRepairs)           AsmManager.getDefault().processDelta(files,state.getAddedFiles(),state.getDeletedFiles());
        }
      }
      if (!files.isEmpty()) {
        CompilationAndWeavingContext.leavingPhase(ct);
        return batchBuild(buildConfig,baseHandler);
      }
 else {
        if (AsmManager.isReporting())         AsmManager.getDefault().reportModelInfo("String_Node_Str");
      }
    }
    if (buildConfig.isEmacsSymMode()) {
      new org.aspectj.ajdt.internal.core.builder.EmacsStructureModelManager().externalizeModel();
    }
    if (buildConfig.isGenerateCrossRefsMode()) {
      File configFileProxy=new File(buildConfig.getOutputDir(),CROSSREFS_FILE_NAME);
      AsmManager.getDefault().writeStructureModel(configFileProxy.getAbsolutePath());
    }
    state.successfulCompile(buildConfig,batch);
    copyResourcesToDestination();
    if (buildConfig.getOutxmlName() != null) {
      writeOutxmlFile();
    }
    if (buildConfig.isGenerateModelMode()) {
      AsmManager.getDefault().fireModelUpdated();
    }
    CompilationAndWeavingContext.leavingPhase(ct);
  }
  finally {
    if (baseHandler instanceof ILifecycleAware) {
      ((ILifecycleAware)baseHandler).buildFinished(!batch);
    }
    if (zos != null) {
      closeOutputStream(buildConfig.getOutputJar());
    }
    ret=!handler.hasErrors();
    if (getBcelWorld() != null)     getBcelWorld().tidyUp();
    if (getWeaver() != null)     getWeaver().tidyUp();
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @throws AbortException if check for runtime fails 
 */
protected boolean doBuild(AjBuildConfig buildConfig,IMessageHandler baseHandler,boolean batch) throws IOException, AbortException {
  boolean ret=true;
  batchCompile=batch;
  wasFullBuild=batch;
  if (baseHandler instanceof ILifecycleAware) {
    ((ILifecycleAware)baseHandler).buildStarting(!batch);
  }
  CompilationAndWeavingContext.reset();
  int phase=batch ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD;
  ContextToken ct=CompilationAndWeavingContext.enteringPhase(phase,buildConfig);
  try {
    if (batch) {
      this.state=new AjState(this);
    }
    this.state.setCouldBeSubsequentIncrementalBuild(this.environmentSupportsIncrementalCompilation);
    boolean canIncremental=state.prepareForNextBuild(buildConfig);
    if (!canIncremental && !batch) {
      CompilationAndWeavingContext.leavingPhase(ct);
      if (state.listenerDefined())       state.getListener().recordDecision("String_Node_Str");
      return doBuild(buildConfig,baseHandler,true);
    }
    this.handler=CountingMessageHandler.makeCountingMessageHandler(baseHandler);
    if (buildConfig == null || buildConfig.isCheckRuntimeVersion()) {
      if (DO_RUNTIME_VERSION_CHECK) {
        String check=checkRtJar(buildConfig);
        if (check != null) {
          if (FAIL_IF_RUNTIME_NOT_FOUND) {
            MessageUtil.error(handler,check);
            CompilationAndWeavingContext.leavingPhase(ct);
            return false;
          }
 else {
            MessageUtil.warn(handler,check);
          }
        }
      }
    }
    setBuildConfig(buildConfig);
    if (batch || !AsmManager.attemptIncrementalModelRepairs) {
      setupModel(buildConfig);
    }
    if (batch) {
      initBcelWorld(handler);
    }
    if (handler.hasErrors()) {
      CompilationAndWeavingContext.leavingPhase(ct);
      return false;
    }
    if (buildConfig.getOutputJar() != null) {
      if (!openOutputStream(buildConfig.getOutputJar())) {
        CompilationAndWeavingContext.leavingPhase(ct);
        return false;
      }
    }
    if (batch) {
      if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode()) {
        getWorld().setModel(AsmManager.getDefault().getHierarchy());
      }
      binarySourcesForTheNextCompile=state.getBinaryFilesToCompile(true);
      performCompilation(buildConfig.getFiles());
      state.clearBinarySourceFiles();
      if (!proceedOnError() && handler.hasErrors()) {
        CompilationAndWeavingContext.leavingPhase(ct);
        if (AsmManager.isReporting())         AsmManager.getDefault().reportModelInfo("String_Node_Str");
        return false;
      }
      if (AsmManager.isReporting())       AsmManager.getDefault().reportModelInfo("String_Node_Str");
    }
 else {
      binarySourcesForTheNextCompile=state.getBinaryFilesToCompile(true);
      Set files=state.getFilesToCompile(true);
      if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode())       if (AsmManager.attemptIncrementalModelRepairs)       AsmManager.getDefault().processDelta(files,state.getAddedFiles(),state.getDeletedFiles());
      boolean hereWeGoAgain=!(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty());
      for (int i=0; (i < 5) && hereWeGoAgain; i++) {
        if (state.listenerDefined())         state.getListener().recordInformation("String_Node_Str" + (i + 1) + "String_Node_Str");
        performCompilation(files);
        if ((!proceedOnError() && handler.hasErrors()) || (progressListener != null && progressListener.isCancelledRequested())) {
          CompilationAndWeavingContext.leavingPhase(ct);
          return false;
        }
        if (state.requiresFullBatchBuild()) {
          if (state.listenerDefined())           state.getListener().recordInformation("String_Node_Str");
          return batchBuild(buildConfig,baseHandler);
        }
        binarySourcesForTheNextCompile=state.getBinaryFilesToCompile(false);
        files=state.getFilesToCompile(false);
        hereWeGoAgain=!(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty());
        if (hereWeGoAgain) {
          if (buildConfig.isEmacsSymMode() || buildConfig.isGenerateModelMode())           if (AsmManager.attemptIncrementalModelRepairs)           AsmManager.getDefault().processDelta(files,state.getAddedFiles(),state.getDeletedFiles());
        }
      }
      if (!files.isEmpty()) {
        CompilationAndWeavingContext.leavingPhase(ct);
        return batchBuild(buildConfig,baseHandler);
      }
 else {
        if (AsmManager.isReporting())         AsmManager.getDefault().reportModelInfo("String_Node_Str");
      }
    }
    if (buildConfig.isEmacsSymMode()) {
      new org.aspectj.ajdt.internal.core.builder.EmacsStructureModelManager().externalizeModel();
    }
    if (buildConfig.isGenerateCrossRefsMode()) {
      File configFileProxy=new File(buildConfig.getOutputDir(),CROSSREFS_FILE_NAME);
      AsmManager.getDefault().writeStructureModel(configFileProxy.getAbsolutePath());
    }
    state.successfulCompile(buildConfig,batch);
    copyResourcesToDestination();
    if (buildConfig.getOutxmlName() != null) {
      writeOutxmlFile();
    }
    if (buildConfig.isGenerateModelMode()) {
      AsmManager.getDefault().fireModelUpdated();
    }
    CompilationAndWeavingContext.leavingPhase(ct);
  }
  finally {
    if (baseHandler instanceof ILifecycleAware) {
      ((ILifecycleAware)baseHandler).buildFinished(!batch);
    }
    if (zos != null) {
      closeOutputStream(buildConfig.getOutputJar());
    }
    ret=!handler.hasErrors();
    if (getBcelWorld() != null)     getBcelWorld().tidyUp();
    if (getWeaver() != null)     getWeaver().tidyUp();
  }
  return ret;
}