Buggy code:
public class CompilationUnit extends Openable implements ICompilationUnit , org . eclipse . jdt . internal . compiler . env . ICompilationUnit { public static boolean SHARED_WC_VERBOSE = false ; protected CompilationUnit ( IPackageFragment parent , String name ) { } public void accept ( IAbstractSyntaxTreeVisitor visitor ) throws JavaModelException { } protected void buildStructure ( OpenableElementInfo info , final IProblemRequestor problemRequestor , IProgressMonitor pm ) throws JavaModelException { } public void codeComplete ( int offset , ICompletionRequestor requestor ) throws JavaModelException { } public IJavaElement [ ] codeSelect ( int offset , int length ) throws JavaModelException { } public void commit ( boolean force , IProgressMonitor monitor ) throws JavaModelException { } public void copy ( IJavaElement container , IJavaElement sibling , String rename , boolean force , IProgressMonitor monitor ) throws JavaModelException { } protected OpenableElementInfo createElementInfo ( ) { } public IImportDeclaration createImport ( String name , IJavaElement sibling , IProgressMonitor monitor ) throws JavaModelException { } public IPackageDeclaration createPackageDeclaration ( String name , IProgressMonitor monitor ) throws JavaModelException { } public IType createType ( String content , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException { } public void delete ( boolean force , IProgressMonitor monitor ) throws JavaModelException { } public void destroy ( ) { } public boolean equals ( Object o ) { } protected boolean equalsDOMNode ( IDOMNode node ) throws JavaModelException { } public IJavaElement findCorrespondingElement ( IJavaElement element ) { ArrayList children = new ArrayList ( ) ; while ( ( element != null ) && ( ( element . getElementType ( ) ) != ( IJavaElement . COMPILATION_UNIT ) ) ) { children . add ( element ) ; element = element . getParent ( ) ; } if ( element == null ) return null ; IJavaElement currentElement = this ; for ( int i = ( children . size ( ) ) - 1 ; i >= 0 ; i -- ) { IJavaElement child = ( ( IJavaElement ) ( children . get ( i ) ) ) ; switch ( child . getElementType ( ) ) { case IJavaElement . PACKAGE_DECLARATION : currentElement = ( ( ICompilationUnit ) ( currentElement ) ) . getPackageDeclaration ( child . getElementName ( ) ) ; break ; case IJavaElement . IMPORT_CONTAINER : currentElement = ( ( ICompilationUnit ) ( currentElement ) ) . getImportContainer ( ) ; break ; case IJavaElement . IMPORT_DECLARATION : currentElement = ( ( IImportContainer ) ( currentElement ) ) . getImport ( child . getElementName ( ) ) ; break ; case IJavaElement . TYPE : if ( ( currentElement . getElementType ( ) ) == ( IJavaElement . COMPILATION_UNIT ) ) { currentElement = ( ( ICompilationUnit ) ( currentElement ) ) . getType ( child . getElementName ( ) ) ; } else { currentElement = ( ( IType ) ( currentElement ) ) . getType ( child . getElementName ( ) ) ; } break ; case IJavaElement . INITIALIZER : currentElement = ( ( IType ) ( currentElement ) ) . getInitializer ( ( ( JavaElement ) ( child ) ) . getOccurrenceCount ( ) ) ; break ; case IJavaElement . FIELD : currentElement = ( ( IType ) ( currentElement ) ) . getField ( child . getElementName ( ) ) ; break ; case IJavaElement . METHOD : currentElement = ( ( IType ) ( currentElement ) ) . findCorrespondingMethod ( ( ( IMethod ) ( child ) ) ) ; break ; } } <START_BUG> if ( currentElement . exists ( ) ) { <END_BUG> return currentElement ; } else { return null ; } } public IType findPrimaryType ( ) { } public IJavaElement findSharedWorkingCopy ( ) { } protected boolean generateInfos ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource , IProblemRequestor problemRequestor ) throws JavaModelException { } public IType [ ] getAllTypes ( ) throws JavaModelException { } public ICompilationUnit getCompilationUnit ( ) { } public char [ ] getContents ( ) { } public IResource getCorrespondingResource ( ) throws JavaModelException { } public IJavaElement getElementAt ( int position ) throws JavaModelException { } public char [ ] getFileName ( ) { } protected char getHandleMementoDelimiter ( ) { } public IImportDeclaration getImport ( String name ) { } public IImportContainer getImportContainer ( ) { } public IImportDeclaration [ ] getImports ( ) throws JavaModelException { } public char [ ] getMainTypeName ( ) { } public IJavaElement getOriginal ( IJavaElement workingCopyElement ) { } public IJavaElement getOriginalElement ( ) { } public IPackageDeclaration getPackageDeclaration ( String name ) { } public IPackageDeclaration [ ] getPackageDeclarations ( ) throws JavaModelException { } public char [ ] [ ] getPackageName ( ) { } public IPath getPath ( ) { } public IResource getResource ( ) { } public String getSource ( ) throws JavaModelException { } public ISourceRange getSourceRange ( ) throws JavaModelException { } public IType getType ( String name ) { } public IType [ ] getTypes ( ) throws JavaModelException { } public IJavaElement getSharedWorkingCopy ( IProgressMonitor pm , IBufferFactory factory ) throws JavaModelException { } public IJavaElement getSharedWorkingCopy ( IProgressMonitor pm , IBufferFactory factory , IProblemRequestor problemRequestor ) throws JavaModelException { } public IJavaElement getWorkingCopy ( ) throws JavaModelException { } public IJavaElement getWorkingCopy ( IProgressMonitor pm , IBufferFactory factory ) throws JavaModelException { } public IJavaElement getWorkingCopy ( IProgressMonitor pm , IBufferFactory factory , IProblemRequestor problemRequestor ) throws JavaModelException { } protected boolean hasBuffer ( ) { } public boolean hasChildren ( ) throws JavaModelException { } public boolean isBasedOn ( IResource resource ) { } public boolean isConsistent ( ) throws JavaModelException { } protected boolean isSourceElement ( ) { } public boolean isWorkingCopy ( ) { } public void makeConsistent ( IProblemRequestor problemRequestor , IProgressMonitor pm ) throws JavaModelException { }

Fix:
if ( ( currentElement != null ) && ( currentElement . exists ( ) ) ) {