Buggy code:
public class ClassFile extends Openable implements IClassFile , SuffixConstants { protected BinaryType binaryType = null ; private boolean checkAutomaticSourceMapping ; protected ClassFile ( PackageFragment parent , String name ) { } protected boolean buildStructure ( OpenableElementInfo info , IProgressMonitor pm , Map newElements , IResource underlyingResource ) throws JavaModelException { } public void codeComplete ( int offset , ICompletionRequestor requestor ) throws JavaModelException { } public void codeComplete ( int offset , ICompletionRequestor requestor , WorkingCopyOwner owner ) throws JavaModelException { } public IJavaElement [ ] codeSelect ( int offset , int length ) throws JavaModelException { } public IJavaElement [ ] codeSelect ( int offset , int length , WorkingCopyOwner owner ) throws JavaModelException { } protected Object createElementInfo ( ) { } public boolean equals ( Object o ) { } public boolean exists ( ) { } protected IJavaElement findElement ( IJavaElement elt , int position , SourceMapper mapper ) { } public IBinaryType getBinaryTypeInfo ( IFile file ) throws JavaModelException { } public IBuffer getBuffer ( ) throws JavaModelException { } public IClassFile getClassFile ( ) { } public IResource getCorrespondingResource ( ) throws JavaModelException { } public IJavaElement getElementAt ( int position ) throws JavaModelException { } public int getElementType ( ) { } public IJavaElement getHandleFromMemento ( String token , StringTokenizer memento , WorkingCopyOwner owner ) { } protected char getHandleMementoDelimiter ( ) { } public IPath getPath ( ) { } public IResource getResource ( ) { } public String getSource ( ) throws JavaModelException { } public ISourceRange getSourceRange ( ) throws JavaModelException { } public String getTopLevelTypeName ( ) { } public IType getType ( ) { } public ICompilationUnit getWorkingCopy ( WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { } public IJavaElement getWorkingCopy ( IProgressMonitor monitor , IBufferFactory factory ) throws JavaModelException { } protected boolean hasBuffer ( ) { } public boolean hasChildren ( ) throws JavaModelException { } public boolean isClass ( ) throws JavaModelException { } public boolean isInterface ( ) throws JavaModelException { } public boolean isReadOnly ( ) { } private boolean isValidClassFile ( ) { } protected IBuffer openBuffer ( IProgressMonitor pm , Object info ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { return mapSource ( mapper ) ; } else if ( ! ( this . checkAutomaticSourceMapping ) ) { PackageFragmentRoot root = getPackageFragmentRoot ( ) ; if ( root . isArchive ( ) ) { String elementName = getElementName ( ) ; StringBuffer sourceFileName = new StringBuffer ( elementName . substring ( 0 , elementName . lastIndexOf ( '.' ) ) ) ; sourceFileName . append ( SuffixConstants . SUFFIX_java ) ; JarPackageFragmentRoot jarPackageFragmentRoot = ( ( JarPackageFragmentRoot ) ( root ) ) ; ZipFile jar = null ; try { jar = jarPackageFragmentRoot . getJar ( ) ; IPackageFragment packageFragment = ( ( IPackageFragment ) ( getParent ( ) ) ) ; ZipEntry zipEntry = null ; if ( packageFragment . isDefaultPackage ( ) ) { zipEntry = jar . getEntry ( sourceFileName . toString ( ) ) ; } else { zipEntry = jar . getEntry ( ( ( ( getParent ( ) . getElementName ( ) ) + '//' ) + ( sourceFileName . toString ( ) ) ) ) ; } if ( zipEntry != null ) { this . checkAutomaticSourceMapping = true ; root . attachSource ( root . getPath ( ) , null , null ) ; SourceMapper sourceMapper = getSourceMapper ( ) ; if ( sourceMapper != null ) { return mapSource ( sourceMapper ) ; } } } catch ( CoreException e ) { if ( e instanceof JavaModelException ) throw ( ( JavaModelException ) ( e ) ) ; throw new JavaModelException ( e ) ; } finally { JavaModelManager . getJavaModelManager ( ) . closeZipFile ( jar ) ; } } else { String qualifiedName = getType ( ) . getFullyQualifiedName ( ) ; <START_BUG> NameLookup lookup = ( ( JavaProject ) ( getJavaProject ( ) ) ) . getNameLookup ( ) ; <END_BUG> ICompilationUnit cu = lookup . findCompilationUnit ( qualifiedName ) ; if ( cu != null ) { return cu . getBuffer ( ) ; } else { IPath sourceFilePath = getPath ( ) . removeFileExtension ( ) . addFileExtension ( SuffixConstants . EXTENSION_java ) ; IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; if ( workspace == null ) { this . checkAutomaticSourceMapping = true ; return null ; } if ( ( JavaModel . getTarget ( workspace . getRoot ( ) , sourceFilePath . makeRelative ( ) , true ) ) != null ) { this . checkAutomaticSourceMapping = true ; root . attachSource ( root . getPath ( ) , null , null ) ; SourceMapper sourceMapper = getSourceMapper ( ) ; if ( sourceMapper != null ) { return mapSource ( sourceMapper ) ; } } } } } return null ; } private IBuffer mapSource ( SourceMapper mapper ) { } static char [ ] simpleName ( char [ ] className ) { } public static char [ ] translatedName ( char [ ] name ) { } static char [ ] [ ] translatedNames ( char [ ] [ ] names ) { } static char [ ] unqualifiedName ( char [ ] className ) { } public void codeComplete ( int offset , final ICodeCompletionRequestor requestor ) throws JavaModelException { } }

Fix:
NameLookup lookup = ( ( JavaProject ) ( getJavaProject ( ) ) ) . newNameLookup ( DefaultWorkingCopyOwner . PRIMARY ) ;