Program: 185571
Project: 185571
Buggy source:
void faultInImports(){
  if (this.typeOrPackageCache != null)   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();
  int index=defaultImports.length;
  ImportBinding[] resolvedImports=new ImportBinding[numberOfImports + index - 1];
  System.arraycopy(defaultImports,0,resolvedImports,0,index);
  nextImport:   for (int i=0; i < numberOfStatements; i++) {
    ImportReference importReference=this.referenceContext.imports[i];
    char[][] compoundName=importReference.getImportName();
    for (int j=0; j < index; j++) {
      ImportBinding resolved=resolvedImports[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;
      }
      resolvedImports[index++]=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 {
          recordImportProblem(importReference,importBinding);
          continue nextImport;
        }
      }
      if (importBinding instanceof PackageBinding) {
        problemReporter().cannotImportPackage(importReference);
        continue nextImport;
      }
      ReferenceBinding conflictingType=null;
      if (importBinding instanceof MethodBinding) {
        conflictingType=(ReferenceBinding)getType(compoundName,compoundName.length);
        if (!conflictingType.isValidBinding() || (importReference.isStatic() && !conflictingType.isStatic()))         conflictingType=null;
      }
      if (importBinding instanceof ReferenceBinding || conflictingType != null) {
        ReferenceBinding referenceBinding=conflictingType == null ? (ReferenceBinding)importBinding : conflictingType;
        ReferenceBinding typeToCheck=referenceBinding.problemId() == ProblemReasons.Ambiguous ? ((ProblemReferenceBinding)referenceBinding).closestMatch : referenceBinding;
        if (importReference.isTypeUseDeprecated(typeToCheck,this))         problemReporter().deprecatedType(typeToCheck,importReference);
        ReferenceBinding existingType=typesBySimpleNames.get(importReference.getSimpleName());
        if (existingType != null) {
          if (existingType == referenceBinding) {
            for (int j=0; j < index; j++) {
              ImportBinding resolved=resolvedImports[j];
              if (resolved instanceof ImportConflictBinding) {
                ImportConflictBinding importConflictBinding=(ImportConflictBinding)resolved;
                if (importConflictBinding.conflictingTypeBinding == referenceBinding) {
                  if (!importReference.isStatic()) {
                    problemReporter().duplicateImport(importReference);
                    resolvedImports[index++]=new ImportBinding(compoundName,false,importBinding,importReference);
                  }
                }
              }
 else               if (resolved.resolvedImport == referenceBinding) {
                if (importReference.isStatic() != resolved.isStatic()) {
                  problemReporter().duplicateImport(importReference);
                  resolvedImports[index++]=new ImportBinding(compoundName,false,importBinding,importReference);
                }
              }
            }
            continue nextImport;
          }
          for (int j=0, length=this.topLevelTypes.length; j < length; j++) {
            if (CharOperation.equals(this.topLevelTypes[j].sourceName,existingType.sourceName)) {
              problemReporter().conflictingImport(importReference);
              continue nextImport;
            }
          }
          problemReporter().duplicateImport(importReference);
          continue nextImport;
        }
        typesBySimpleNames.put(importReference.getSimpleName(),referenceBinding);
      }
 else       if (importBinding instanceof FieldBinding) {
        for (int j=0; j < index; j++) {
          ImportBinding resolved=resolvedImports[j];
          if (resolved.isStatic() && resolved.resolvedImport instanceof FieldBinding && importBinding != resolved.resolvedImport) {
            if (CharOperation.equals(compoundName[compoundName.length - 1],resolved.compoundName[resolved.compoundName.length - 1])) {
              problemReporter().duplicateImport(importReference);
              continue nextImport;
            }
          }
        }
      }
      resolvedImports[index++]=conflictingType == null ? new ImportBinding(compoundName,false,importBinding,importReference) : new ImportConflictBinding(compoundName,importBinding,conflictingType,importReference);
    }
  }
  if (resolvedImports.length > index)   System.arraycopy(resolvedImports,0,resolvedImports=new ImportBinding[index],0,index);
  this.imports=resolvedImports;
  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);
  }
}

Fixed version (ground truth):
void faultInImports(){
  if (this.typeOrPackageCache != null)   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();
  int index=defaultImports.length;
  ImportBinding[] resolvedImports=new ImportBinding[numberOfImports + index - 1];
  System.arraycopy(defaultImports,0,resolvedImports,0,index);
  nextImport:   for (int i=0; i < numberOfStatements; i++) {
    ImportReference importReference=this.referenceContext.imports[i];
    char[][] compoundName=importReference.getImportName();
    for (int j=0; j < index; j++) {
      ImportBinding resolved=resolvedImports[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;
      }
      resolvedImports[index++]=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 {
          reportImportProblem(importReference,importBinding);
          continue nextImport;
        }
      }
      if (importBinding instanceof PackageBinding) {
        problemReporter().cannotImportPackage(importReference);
        continue nextImport;
      }
      ReferenceBinding conflictingType=null;
      if (importBinding instanceof MethodBinding) {
        conflictingType=(ReferenceBinding)getType(compoundName,compoundName.length);
        if (!conflictingType.isValidBinding() || (importReference.isStatic() && !conflictingType.isStatic()))         conflictingType=null;
      }
      if (importBinding instanceof ReferenceBinding || conflictingType != null) {
        ReferenceBinding referenceBinding=conflictingType == null ? (ReferenceBinding)importBinding : conflictingType;
        ReferenceBinding typeToCheck=referenceBinding.problemId() == ProblemReasons.Ambiguous ? ((ProblemReferenceBinding)referenceBinding).closestMatch : referenceBinding;
        if (importReference.isTypeUseDeprecated(typeToCheck,this))         problemReporter().deprecatedType(typeToCheck,importReference);
        ReferenceBinding existingType=typesBySimpleNames.get(importReference.getSimpleName());
        if (existingType != null) {
          if (existingType == referenceBinding) {
            for (int j=0; j < index; j++) {
              ImportBinding resolved=resolvedImports[j];
              if (resolved instanceof ImportConflictBinding) {
                ImportConflictBinding importConflictBinding=(ImportConflictBinding)resolved;
                if (importConflictBinding.conflictingTypeBinding == referenceBinding) {
                  if (!importReference.isStatic()) {
                    problemReporter().duplicateImport(importReference);
                    resolvedImports[index++]=new ImportBinding(compoundName,false,importBinding,importReference);
                  }
                }
              }
 else               if (resolved.resolvedImport == referenceBinding) {
                if (importReference.isStatic() != resolved.isStatic()) {
                  problemReporter().duplicateImport(importReference);
                  resolvedImports[index++]=new ImportBinding(compoundName,false,importBinding,importReference);
                }
              }
            }
            continue nextImport;
          }
          for (int j=0, length=this.topLevelTypes.length; j < length; j++) {
            if (CharOperation.equals(this.topLevelTypes[j].sourceName,existingType.sourceName)) {
              problemReporter().conflictingImport(importReference);
              continue nextImport;
            }
          }
          problemReporter().duplicateImport(importReference);
          continue nextImport;
        }
        typesBySimpleNames.put(importReference.getSimpleName(),referenceBinding);
      }
 else       if (importBinding instanceof FieldBinding) {
        for (int j=0; j < index; j++) {
          ImportBinding resolved=resolvedImports[j];
          if (resolved.isStatic() && resolved.resolvedImport instanceof FieldBinding && importBinding != resolved.resolvedImport) {
            if (CharOperation.equals(compoundName[compoundName.length - 1],resolved.compoundName[resolved.compoundName.length - 1])) {
              problemReporter().duplicateImport(importReference);
              continue nextImport;
            }
          }
        }
      }
      resolvedImports[index++]=conflictingType == null ? new ImportBinding(compoundName,false,importBinding,importReference) : new ImportConflictBinding(compoundName,importBinding,conflictingType,importReference);
    }
  }
  if (resolvedImports.length > index)   System.arraycopy(resolvedImports,0,resolvedImports=new ImportBinding[index],0,index);
  this.imports=resolvedImports;
  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);
  }
}