Buggy code:
public MethodBinding getMethodBinding ( MethodPattern methodPattern ) { } protected boolean hasAlreadyDefinedType ( CompilationUnitDeclaration parsedUnit ) { } public void initialize ( JavaProject project , int possibleMatchSize ) throws JavaModelException { } protected void locateMatches ( JavaProject javaProject , PossibleMatch [ ] possibleMatches , int start , int length ) throws CoreException { } protected void locateMatches ( JavaProject javaProject , PossibleMatchSet matchSet , int expected ) throws CoreException { } public void locateMatches ( SearchDocument [ ] searchDocuments ) throws CoreException { } public void locatePackageDeclarations ( SearchParticipant participant ) throws CoreException { } protected void locatePackageDeclarations ( SearchPattern searchPattern , SearchParticipant participant ) throws CoreException { } protected IType lookupType ( ReferenceBinding typeBinding ) { } public SearchMatch newDeclarationMatch ( IJavaElement element , Binding binding , int accuracy , int offset , int length ) { } public SearchMatch newDeclarationMatch ( IJavaElement element , Binding binding , int accuracy , int offset , int length , SearchParticipant participant , IResource resource ) { } public SearchMatch newFieldReferenceMatch ( IJavaElement enclosingElement , Binding enclosingBinding , int accuracy , int offset , int length , ASTNode reference ) { } public SearchMatch newLocalVariableReferenceMatch ( IJavaElement enclosingElement , int accuracy , int offset , int length , ASTNode reference ) { } public SearchMatch newMethodReferenceMatch ( IJavaElement enclosingElement , Binding enclosingBinding , int accuracy , int offset , int length , boolean isConstructor , boolean isSynthetic , ASTNode reference ) { } public SearchMatch newPackageReferenceMatch ( IJavaElement enclosingElement , int accuracy , int offset , int length , ASTNode reference ) { } public SearchMatch newTypeParameterReferenceMatch ( IJavaElement enclosingElement , int accuracy , int offset , int length , ASTNode reference ) { } public TypeReferenceMatch newTypeReferenceMatch ( IJavaElement enclosingElement , Binding enclosingBinding , int accuracy , int offset , int length , ASTNode reference ) { } public TypeReferenceMatch newTypeReferenceMatch ( IJavaElement enclosingElement , Binding enclosingBinding , int accuracy , ASTNode reference ) { } protected boolean parseAndBuildBindings ( PossibleMatch possibleMatch , boolean mustResolve ) throws CoreException { } protected void process ( PossibleMatch possibleMatch , boolean bindingsWereCreated ) throws CoreException { } protected void purgeMethodStatements ( TypeDeclaration type , boolean checkEachMethod ) { } protected void reduceParseTree ( CompilationUnitDeclaration unit ) { } public SearchParticipant getParticipant ( ) { } protected void report ( SearchMatch match ) throws CoreException { } protected void reportAccurateTypeReference ( SearchMatch match , ASTNode typeRef , char [ ] name ) throws CoreException { } protected void reportAccurateParameterizedMethodReference ( SearchMatch match , ASTNode statement , TypeReference [ ] typeArguments ) throws CoreException { } protected void reportAccurateParameterizedTypeReference ( SearchMatch match , TypeReference typeRef , int index , TypeReference [ ] typeArguments ) throws CoreException { } protected void reportAccurateEnumConstructorReference ( SearchMatch match , FieldDeclaration field , AllocationExpression allocation ) throws CoreException { } protected void reportAccurateFieldReference ( SearchMatch [ ] matches , QualifiedNameReference qNameRef ) throws CoreException { } protected void reportBinaryMemberDeclaration ( IResource resource , IMember binaryMember , Binding binaryMemberBinding , IBinaryType info , int accuracy ) throws CoreException { } protected void reportMatching ( TypeDeclaration type , AbstractMethodDeclaration method , IJavaElement parent , int accuracy , boolean typeInHierarchy , MatchingNodeSet nodeSet ) throws CoreException { } protected void reportMatching ( Annotation [ ] annotations , IJavaElement enclosingElement , Binding elementBinding , MatchingNodeSet nodeSet , boolean matchedContainer , boolean enclosesElement ) throws CoreException { } protected void reportMatching ( CompilationUnitDeclaration unit , boolean mustResolve ) throws CoreException { } protected void reportMatching ( FieldDeclaration field , FieldDeclaration [ ] otherFields , TypeDeclaration type , IJavaElement parent , int accuracy , boolean typeInHierarchy , MatchingNodeSet nodeSet ) throws CoreException { } protected void reportMatching ( TypeDeclaration type , IJavaElement parent , int accuracy , MatchingNodeSet nodeSet , int occurrenceCount ) throws CoreException { IJavaElement enclosingElement = parent ; if ( enclosingElement == null ) { enclosingElement = createTypeHandle ( new String ( type . name ) ) ; } else if ( enclosingElement instanceof IType ) { enclosingElement = ( ( IType ) ( parent ) ) . getType ( new String ( type . name ) ) ; } else if ( enclosingElement instanceof IMember ) { IMember member = ( ( IMember ) ( parent ) ) ; if ( member . isBinary ( ) ) { <START_BUG> enclosingElement = this . currentPossibleMatch . openable . getClassFile ( ) . getType ( ) ; <END_BUG> } else { enclosingElement = member . getType ( new String ( type . name ) , occurrenceCount ) ; } } if ( enclosingElement == null ) return ; boolean enclosesElement = encloses ( enclosingElement ) ; if ( ( accuracy > ( - 1 ) ) && enclosesElement ) { int offset = type . sourceStart ; SearchMatch match = this . patternLocator . newDeclarationMatch ( type , enclosingElement , type . binding , accuracy , ( ( ( type . sourceEnd ) - offset ) + 1 ) , this ) ; report ( match ) ; } boolean matchedClassContainer = ( ( this . matchContainer ) & ( PatternLocator . CLASS_CONTAINER ) ) != 0 ; if ( ( type . typeParameters ) != null ) { reportMatching ( type . typeParameters , enclosingElement , parent , type . binding , nodeSet ) ; } if ( ( type . annotations ) != null ) { reportMatching ( type . annotations , enclosingElement , type . binding , nodeSet , matchedClassContainer , enclosesElement ) ; } if ( ( type . javadoc ) != null ) { ASTNode [ ] nodes = nodeSet . matchingNodes ( type . declarationSourceStart , type . sourceStart ) ; if ( nodes != null ) { if ( ! matchedClassContainer ) { for ( int i = 0 , l = nodes . length ; i < l ; i ++ ) nodeSet . matchingNodes . removeKey ( nodes [ i ] ) ; }

Fix:
enclosingElement = ( ( IClassFile ) ( this . currentPossibleMatch . openable ) ) . getType ( ) ;