Program: 185577
Project: 185577
Buggy source:
void faultInImports(){
  boolean unresolvedFound=false;
  boolean reportUnresolved=!this.suppressImportErrors;
  if (this.typeOrPackageCache != null && !this.skipCachingImports)   return;
  if (this.referenceContext.imports == null) {
    this.typeOrPackageCache=new HashtableOfObject(1);
    return;
  }
  int numberOfStatements=this.referenceContext.imports.length;
  HashtableOfType typesBySimpleNames=null;
  for (int i=0; i < numberOfStatements; i++) {
    if ((this.referenceContext.imports[i].bits & ASTNode.OnDemand) == 0) {
      typesBySimpleNames=new HashtableOfType(this.topLevelTypes.length + numberOfStatements);
      for (int j=0, length=this.topLevelTypes.length; j < length; j++)       typesBySimpleNames.put(this.topLevelTypes[j].sourceName,this.topLevelTypes[j]);
      break;
    }
  }
  int numberOfImports=numberOfStatements + 1;
  for (int i=0; i < numberOfStatements; i++) {
    ImportReference importReference=this.referenceContext.imports[i];
    if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG,importReference.tokens) && !importReference.isStatic()) {
      numberOfImports--;
      break;
    }
  }
  ImportBinding[] defaultImports=getDefaultImports();
  this.importPtr=defaultImports.length;
  this.tempImports=new ImportBinding[numberOfImports + this.importPtr - 1];
  System.arraycopy(defaultImports,0,this.tempImports,0,this.importPtr);
  nextImport:   for (int i=0; i < numberOfStatements; i++) {
    ImportReference importReference=this.referenceContext.imports[i];
    char[][] compoundName=importReference.getImportName();
    for (int j=0; j < this.importPtr; j++) {
      ImportBinding resolved=this.tempImports[j];
      if (resolved.onDemand == ((importReference.bits & ASTNode.OnDemand) != 0) && resolved.isStatic() == importReference.isStatic()) {
        if (CharOperation.equals(compoundName,resolved.compoundName) && CharOperation.equals(importReference.getSimpleName(),getSimpleName(resolved))) {
          problemReporter().unusedImport(importReference);
          continue nextImport;
        }
      }
    }
    if ((importReference.bits & ASTNode.OnDemand) != 0) {
      if (CharOperation.equals(compoundName,this.currentPackageName)) {
        problemReporter().unusedImport(importReference);
        continue nextImport;
      }
      Binding importBinding=findImport(compoundName,compoundName.length);
      if (!importBinding.isValidBinding()) {
        reportImportProblem(importReference,importBinding);
        continue nextImport;
      }
      if (importReference.isStatic() && importBinding instanceof PackageBinding) {
        problemReporter().cannotImportPackage(importReference);
        continue nextImport;
      }
      recordImportBinding(new ImportBinding(compoundName,true,importBinding,importReference));
    }
 else {
      Binding importBinding=findSingleImport(compoundName,Binding.TYPE | Binding.FIELD | Binding.METHOD,importReference.isStatic());
      if (!importBinding.isValidBinding()) {
        if (importBinding.problemId() == ProblemReasons.Ambiguous) {
        }
 else {
          unresolvedFound=true;
          if (reportUnresolved) {
            recordImportProblem(importReference,importBinding);
          }
          continue nextImport;
        }
      }
      if (importBinding instanceof PackageBinding) {
        problemReporter().cannotImportPackage(importReference);
        continue nextImport;
      }
      if (checkAndRecordImportBinding(importBinding,typesBySimpleNames,importReference,compoundName) == -1)       continue nextImport;
      if (importReference.isStatic()) {
        if (importBinding.kind() == Binding.FIELD) {
          checkMoreStaticBindings(compoundName,typesBySimpleNames,Binding.TYPE | Binding.METHOD,importReference);
        }
 else         if (importBinding.kind() == Binding.METHOD) {
          checkMoreStaticBindings(compoundName,typesBySimpleNames,Binding.TYPE,importReference);
        }
      }
    }
  }
  if (this.tempImports.length > this.importPtr)   System.arraycopy(this.tempImports,0,this.tempImports=new ImportBinding[this.importPtr],0,this.importPtr);
  this.imports=this.tempImports;
  int length=this.imports.length;
  this.typeOrPackageCache=new HashtableOfObject(length);
  for (int i=0; i < length; i++) {
    ImportBinding binding=this.imports[i];
    if (!binding.onDemand && binding.resolvedImport instanceof ReferenceBinding || binding instanceof ImportConflictBinding)     this.typeOrPackageCache.put(getSimpleName(binding),binding);
  }
  this.skipCachingImports=this.suppressImportErrors && unresolvedFound;
}

Fixed version (ground truth):
void faultInImports(){
  boolean unresolvedFound=false;
  boolean reportUnresolved=!this.suppressImportErrors;
  if (this.typeOrPackageCache != null && !this.skipCachingImports)   return;
  if (this.referenceContext.imports == null) {
    this.typeOrPackageCache=new HashtableOfObject(1);
    return;
  }
  int numberOfStatements=this.referenceContext.imports.length;
  HashtableOfType typesBySimpleNames=null;
  for (int i=0; i < numberOfStatements; i++) {
    if ((this.referenceContext.imports[i].bits & ASTNode.OnDemand) == 0) {
      typesBySimpleNames=new HashtableOfType(this.topLevelTypes.length + numberOfStatements);
      for (int j=0, length=this.topLevelTypes.length; j < length; j++)       typesBySimpleNames.put(this.topLevelTypes[j].sourceName,this.topLevelTypes[j]);
      break;
    }
  }
  int numberOfImports=numberOfStatements + 1;
  for (int i=0; i < numberOfStatements; i++) {
    ImportReference importReference=this.referenceContext.imports[i];
    if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG,importReference.tokens) && !importReference.isStatic()) {
      numberOfImports--;
      break;
    }
  }
  ImportBinding[] defaultImports=getDefaultImports();
  this.importPtr=defaultImports.length;
  this.tempImports=new ImportBinding[numberOfImports + this.importPtr - 1];
  System.arraycopy(defaultImports,0,this.tempImports,0,this.importPtr);
  nextImport:   for (int i=0; i < numberOfStatements; i++) {
    ImportReference importReference=this.referenceContext.imports[i];
    char[][] compoundName=importReference.getImportName();
    for (int j=0; j < this.importPtr; j++) {
      ImportBinding resolved=this.tempImports[j];
      if (resolved.onDemand == ((importReference.bits & ASTNode.OnDemand) != 0) && resolved.isStatic() == importReference.isStatic()) {
        if (CharOperation.equals(compoundName,resolved.compoundName) && CharOperation.equals(importReference.getSimpleName(),getSimpleName(resolved))) {
          problemReporter().unusedImport(importReference);
          continue nextImport;
        }
      }
    }
    if ((importReference.bits & ASTNode.OnDemand) != 0) {
      if (CharOperation.equals(compoundName,this.currentPackageName)) {
        problemReporter().unusedImport(importReference);
        continue nextImport;
      }
      Binding importBinding=findImport(compoundName,compoundName.length);
      if (!importBinding.isValidBinding()) {
        reportImportProblem(importReference,importBinding);
        continue nextImport;
      }
      if (importReference.isStatic() && importBinding instanceof PackageBinding) {
        problemReporter().cannotImportPackage(importReference);
        continue nextImport;
      }
      recordImportBinding(new ImportBinding(compoundName,true,importBinding,importReference));
    }
 else {
      Binding importBinding=findSingleImport(compoundName,Binding.TYPE | Binding.FIELD | Binding.METHOD,importReference.isStatic());
      if (!importBinding.isValidBinding()) {
        if (importBinding.problemId() == ProblemReasons.Ambiguous) {
        }
 else {
          unresolvedFound=true;
          if (reportUnresolved) {
            reportImportProblem(importReference,importBinding);
          }
          continue nextImport;
        }
      }
      if (importBinding instanceof PackageBinding) {
        problemReporter().cannotImportPackage(importReference);
        continue nextImport;
      }
      if (checkAndRecordImportBinding(importBinding,typesBySimpleNames,importReference,compoundName) == -1)       continue nextImport;
      if (importReference.isStatic()) {
        if (importBinding.kind() == Binding.FIELD) {
          checkMoreStaticBindings(compoundName,typesBySimpleNames,Binding.TYPE | Binding.METHOD,importReference);
        }
 else         if (importBinding.kind() == Binding.METHOD) {
          checkMoreStaticBindings(compoundName,typesBySimpleNames,Binding.TYPE,importReference);
        }
      }
    }
  }
  if (this.tempImports.length > this.importPtr)   System.arraycopy(this.tempImports,0,this.tempImports=new ImportBinding[this.importPtr],0,this.importPtr);
  this.imports=this.tempImports;
  int length=this.imports.length;
  this.typeOrPackageCache=new HashtableOfObject(length);
  for (int i=0; i < length; i++) {
    ImportBinding binding=this.imports[i];
    if (!binding.onDemand && binding.resolvedImport instanceof ReferenceBinding || binding instanceof ImportConflictBinding)     this.typeOrPackageCache.put(getSimpleName(binding),binding);
  }
  this.skipCachingImports=this.suppressImportErrors && unresolvedFound;
}