Buggy code:
public class MatchLocator implements ITypeRequestor { public SearchPattern pattern ; public int detailLevel ; public IJavaSearchResultCollector collector ; public IJavaSearchScope scope ; public MatchLocatorParser parser ; public LookupEnvironment lookupEnvironment ; public HashtableOfObject parsedUnits ; private PotentialMatch [ ] potentialMatches ; private int potentialMatchesIndex ; private int potentialMatchesLength ; public MatchLocator ( SearchPattern pattern , int detailLevel , IJavaSearchResultCollector collector , IJavaSearchScope scope ) { } public void accept ( IBinaryType binaryType , PackageBinding packageBinding ) { } public void accept ( ICompilationUnit sourceUnit ) { } public void accept ( ISourceType [ ] sourceTypes , PackageBinding packageBinding ) { ISourceType sourceType = sourceTypes [ 0 ] ; while ( ( sourceType . getEnclosingType ( ) ) != null ) sourceType = sourceType . getEnclosingType ( ) ; CompilationUnitDeclaration unit ; if ( sourceType instanceof SourceTypeElementInfo ) { SourceTypeElementInfo elementInfo = ( ( SourceTypeElementInfo ) ( sourceType ) ) ; IType type = elementInfo . getHandle ( ) ; try { final IFile file = ( ( IFile ) ( type . getUnderlyingResource ( ) ) ) ; <START_BUG> final char [ ] source = PotentialMatch . getContents ( file ) ; <END_BUG> final String fileName = file . getFullPath ( ) . lastSegment ( ) ; final char [ ] mainTypeName = fileName . substring ( 0 , ( ( fileName . length ( ) ) - 5 ) ) . toCharArray ( ) ; ICompilationUnit sourceUnit = new ICompilationUnit ( ) { public char [ ] getContents ( ) { return source ; } public char [ ] getFileName ( ) { return fileName . toCharArray ( ) ; } public char [ ] getMainTypeName ( ) { return mainTypeName ; } } ; CompilationResult compilationResult = new CompilationResult ( sourceUnit , 0 , 0 ) ; unit = this . parser . dietParse ( sourceUnit , compilationResult ) ; } catch ( JavaModelException e ) { unit = null ; } } else { CompilationResult result = new CompilationResult ( sourceType . getFileName ( ) , 0 , 0 ) ; unit = SourceTypeConverter . buildCompilationUnit ( sourceTypes , true , true , lookupEnvironment . problemReporter , result ) ; } if ( unit != null ) { this . lookupEnvironment . buildTypeBindings ( unit ) ; this . lookupEnvironment . completeTypeBindings ( unit , true ) ; this . parsedUnits . put ( sourceType . getQualifiedName ( ) , unit ) ; } } private IField createFieldHandle ( FieldDeclaration field , char [ ] [ ] definingTypeNames ) { } private IImportDeclaration createImportHandle ( ImportReference importRef ) { } private IInitializer createInitializerHandle ( TypeDeclaration typeDecl , FieldDeclaration initializer , char [ ] [ ] definingTypeNames ) { } private IMethod createMethodHandle ( AbstractMethodDeclaration method , char [ ] [ ] definingTypeNames ) { } private IType createTypeHandle ( char [ ] [ ] simpleTypeNames ) { } protected IResource getCurrentResource ( ) { } protected Scanner getScanner ( ) { } public void locateMatches ( String [ ] filePaths , IWorkspace workspace ) throws JavaModelException { } public void locatePackageDeclarations ( IWorkspace workspace ) throws JavaModelException { } private void locatePackageDeclarations ( SearchPattern searchPattern , IWorkspace workspace ) throws JavaModelException { } public void report ( int sourceStart , int sourceEnd , IJavaElement element , int accuracy ) throws CoreException { } public void reportBinaryMatch ( IMember binaryMember , IBinaryType info , int accuracy ) throws CoreException , JavaModelException { } public void reportFieldDeclaration ( FieldDeclaration fieldDeclaration , char [ ] [ ] definingTypeNames , int accuracy ) throws CoreException { } public void reportImport ( ImportReference reference , int accuracy ) throws CoreException { } public void reportMethodDeclaration ( AbstractMethodDeclaration methodDeclaration , char [ ] [ ] definingTypeNames , int accuracy ) throws CoreException { } public void reportPackageDeclaration ( ImportReference node ) { } public void reportPackageReference ( ImportReference node ) { } public void reportQualifiedReference ( int sourceStart , int sourceEnd , char [ ] [ ] qualifiedName , IJavaElement element , int accuracy ) throws CoreException { } public void reportReference ( AstNode reference , AbstractMethodDeclaration methodDeclaration , char [ ] [ ] definingTypeNames , int accuracy ) throws CoreException { } public void reportReference ( AstNode reference , TypeDeclaration typeDeclaration , FieldDeclaration fieldDeclaration , char [ ] [ ] definingTypeNames , int accuracy ) throws CoreException { } public void reportSuperTypeReference ( TypeReference typeRef , char [ ] [ ] definingTypeNames , int accuracy ) throws CoreException { } public void reportTypeDeclaration ( TypeDeclaration typeDeclaration , char [ ] [ ] simpleTypeNames , int accuracy ) throws CoreException { } private void addPotentialMatch ( IResource resource , Openable openable ) throws JavaModelException { } private boolean createParser ( JavaProject project ) throws JavaModelException { } protected Openable getCurrentOpenable ( ) { } private void locateMatches ( ) throws JavaModelException { } }

Fix:
final char [ ] source = Util . getResourceContentsAsCharArray ( file ) ;