Program: 53423
Project: 53423
Buggy source:
/** 
 * Takes as input a CompilationState and transforms that into a unified by not yet resolved Java AST (a Java AST wherein cross-class references have been connected and all rebind result classes are available and have not yet been pruned down to the set applicable for a particular permutation). This AST is packaged into a UnifiedAst instance and then returned. Precompilation is INTENDED to progress as a series of stages: <pre> 1. initialize local state 2. assert preconditions 3. construct and unify the unresolved Java AST 4. normalize the unresolved Java AST  // arguably should be removed 5. optimize the unresolved Java AST  // arguably should be removed 6. construct and return a value </pre> There are some other types of work here (mostly metrics and data gathering) which do not serve the goal of output program construction. This work should really be moved into subclasses or some sort of callback or plugin system so as not to visually pollute the real compile logic.<br /> Significant amounts of visitors implementing the intended above stages are triggered here but in the wrong order. They have been noted for future cleanup.
 */
private UnifiedAst precompile(PrecompilationContext precompilationContext) throws UnableToCompleteException {
  try {
    if (precompilationContext.getEntryPoints().length + precompilationContext.getAdditionalRootTypes().length == 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    boolean singlePermutation=precompilationContext.getPermutations().length == 1;
    PrecompilationMetricsArtifact precompilationMetrics=precompilationContext.getPrecompilationMetricsArtifact();
    jprogram=new JProgram(compilerContext.getMinimalRebuildCache());
    jprogram.typeOracle.setOptimize(options.getOptimizationLevel() > OptionOptimize.OPTIMIZE_LEVEL_DRAFT);
    jsProgram=new JsProgram();
    CompilationState compilationState=constructJavaAst(precompilationContext);
    JsniRestrictionChecker.exec(logger,jprogram);
    JsInteropRestrictionChecker.exec(logger,jprogram,getMinimalRebuildCache());
    logTypeOracleMetrics(precompilationMetrics,compilationState);
    Memory.maybeDumpMemory("String_Node_Str");
    AstDumper.maybeDumpAST(jprogram);
    ConfigurationProperties configurationProperties=new ConfigurationProperties(module);
    EnumNameObfuscator.exec(jprogram,logger,configurationProperties,options);
    ReplaceDefenderMethodReferences.exec(jprogram);
    FixAssignmentsToUnboxOrCast.exec(jprogram);
    if (options.isEnableAssertions()) {
      AssertionNormalizer.exec(jprogram);
    }
 else {
      AssertionRemover.exec(jprogram);
    }
    if (module != null && options.isRunAsyncEnabled()) {
      ReplaceRunAsyncs.exec(logger,jprogram);
      ConfigurationProperties config=new ConfigurationProperties(module);
      CodeSplitters.pickInitialLoadSequence(logger,jprogram,config);
    }
    ImplementClassLiteralsAsFields.exec(jprogram);
    logAstTypeMetrics(precompilationMetrics);
    Event createUnifiedAstEvent=SpeedTracerLogger.start(CompilerEventType.CREATE_UNIFIED_AST);
    UnifiedAst result=new UnifiedAst(options,new AST(jprogram,jsProgram),singlePermutation,RecordRebinds.exec(jprogram));
    createUnifiedAstEvent.end();
    return result;
  }
 catch (  Throwable e) {
    throw CompilationProblemReporter.logAndTranslateException(logger,e);
  }
}

Fixed version (ground truth):
/** 
 * Takes as input a CompilationState and transforms that into a unified by not yet resolved Java AST (a Java AST wherein cross-class references have been connected and all rebind result classes are available and have not yet been pruned down to the set applicable for a particular permutation). This AST is packaged into a UnifiedAst instance and then returned. Precompilation is INTENDED to progress as a series of stages: <pre> 1. initialize local state 2. assert preconditions 3. construct and unify the unresolved Java AST 4. normalize the unresolved Java AST  // arguably should be removed 5. optimize the unresolved Java AST  // arguably should be removed 6. construct and return a value </pre> There are some other types of work here (mostly metrics and data gathering) which do not serve the goal of output program construction. This work should really be moved into subclasses or some sort of callback or plugin system so as not to visually pollute the real compile logic.<br /> Significant amounts of visitors implementing the intended above stages are triggered here but in the wrong order. They have been noted for future cleanup.
 */
private UnifiedAst precompile(PrecompilationContext precompilationContext) throws UnableToCompleteException {
  try {
    if (precompilationContext.getEntryPoints().length + precompilationContext.getAdditionalRootTypes().length == 0) {
      throw new IllegalArgumentException("String_Node_Str");
    }
    boolean singlePermutation=precompilationContext.getPermutations().length == 1;
    PrecompilationMetricsArtifact precompilationMetrics=precompilationContext.getPrecompilationMetricsArtifact();
    jprogram=new JProgram(compilerContext.getMinimalRebuildCache());
    jprogram.typeOracle.setOptimize(options.getOptimizationLevel() > OptionOptimize.OPTIMIZE_LEVEL_DRAFT);
    jsProgram=new JsProgram();
    CompilationState compilationState=constructJavaAst(precompilationContext);
    JsniRestrictionChecker.exec(logger,jprogram);
    JsInteropRestrictionChecker.exec(logger,jprogram,getMinimalRebuildCache());
    logTypeOracleMetrics(precompilationMetrics,compilationState);
    Memory.maybeDumpMemory("String_Node_Str");
    AstDumper.maybeDumpAST(jprogram);
    ConfigurationProperties configurationProperties=new ConfigurationProperties(module);
    EnumNameObfuscator.exec(jprogram,logger,configurationProperties,options);
    ReplaceDefenderMethodReferences.exec(jprogram);
    FixAssignmentsToUnboxOrCast.exec(jprogram);
    if (options.isEnableAssertions()) {
      AssertionNormalizer.exec(jprogram);
    }
 else {
      AssertionRemover.exec(jprogram);
    }
    if (module != null && options.isRunAsyncEnabled()) {
      ReplaceRunAsyncs.exec(logger,jprogram);
      ConfigurationProperties config=new ConfigurationProperties(module);
      CodeSplitters.pickInitialLoadSequence(logger,jprogram,config);
    }
    ImplementClassLiteralsAsFields.exec(jprogram,shouldOptimize());
    logAstTypeMetrics(precompilationMetrics);
    Event createUnifiedAstEvent=SpeedTracerLogger.start(CompilerEventType.CREATE_UNIFIED_AST);
    UnifiedAst result=new UnifiedAst(options,new AST(jprogram,jsProgram),singlePermutation,RecordRebinds.exec(jprogram));
    createUnifiedAstEvent.end();
    return result;
  }
 catch (  Throwable e) {
    throw CompilationProblemReporter.logAndTranslateException(logger,e);
  }
}