Buggy code:
public class SourceType extends Member implements IType { protected static final String [ ] fgEmptyList = new String [ ] { } ; protected SourceType ( JavaElement parent , String name ) { } public void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , ICompletionRequestor requestor ) throws JavaModelException { } public void codeComplete ( char [ ] snippet , int insertion , int position , char [ ] [ ] localVariableTypeNames , char [ ] [ ] localVariableNames , int [ ] localVariableModifiers , boolean isStatic , ICompletionRequestor requestor , WorkingCopyOwner owner ) throws JavaModelException { } public IField createField ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException { } public IInitializer createInitializer ( String contents , IJavaElement sibling , IProgressMonitor monitor ) throws JavaModelException { } public IMethod createMethod ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException { } public IType createType ( String contents , IJavaElement sibling , boolean force , IProgressMonitor monitor ) throws JavaModelException { } public boolean equals ( Object o ) { } protected boolean equalsDOMNode ( IDOMNode node ) { } public IMethod [ ] findMethods ( IMethod method ) { } public IType getDeclaringType ( ) { } public int getElementType ( ) { } public IField getField ( String name ) { } public IField [ ] getFields ( ) throws JavaModelException { } public String getFullyQualifiedName ( ) { } public String getFullyQualifiedName ( char enclosingTypeSeparator ) { } public IJavaElement getHandleFromMemento ( String token , StringTokenizer memento , WorkingCopyOwner workingCopyOwner ) { } public IInitializer getInitializer ( int count ) { } public IInitializer [ ] getInitializers ( ) throws JavaModelException { } public IMethod getMethod ( String name , String [ ] parameterTypeSignatures ) { } public IMethod [ ] getMethods ( ) throws JavaModelException { } public IPackageFragment getPackageFragment ( ) { } public IJavaElement getPrimaryElement ( boolean checkOwner ) { if ( checkOwner ) { CompilationUnit cu = ( ( CompilationUnit ) ( getAncestor ( IJavaElement . COMPILATION_UNIT ) ) ) ; <START_BUG> if ( ( cu . owner ) == ( DefaultWorkingCopyOwner . PRIMARY ) ) <END_BUG> return this ; } IJavaElement parent = fParent . getPrimaryElement ( false ) ; switch ( parent . getElementType ( ) ) { case IJavaElement . COMPILATION_UNIT : return ( ( ICompilationUnit ) ( parent ) ) . getType ( fName ) ; case IJavaElement . TYPE : return ( ( IType ) ( parent ) ) . getType ( fName ) ; case IJavaElement . FIELD : case IJavaElement . INITIALIZER : case IJavaElement . METHOD : return ( ( IMember ) ( parent ) ) . getType ( fName , this . occurrenceCount ) ; } return this ; } public String getSuperclassName ( ) throws JavaModelException { } public String [ ] getSuperInterfaceNames ( ) throws JavaModelException { } public IType getType ( String name ) { } public String getTypeQualifiedName ( ) { } public String getTypeQualifiedName ( char enclosingTypeSeparator ) { } public IType [ ] getTypes ( ) throws JavaModelException { } public boolean isAnonymous ( ) { } public boolean isClass ( ) throws JavaModelException { } public boolean isInterface ( ) throws JavaModelException { } public boolean isLocal ( ) { } public boolean isMember ( ) { } public ITypeHierarchy loadTypeHierachy ( InputStream input , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy loadTypeHierachy ( InputStream input , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newSupertypeHierarchy ( IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newSupertypeHierarchy ( IWorkingCopy [ ] workingCopies , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newSupertypeHierarchy ( WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newTypeHierarchy ( IJavaProject project , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newTypeHierarchy ( IJavaProject project , WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newTypeHierarchy ( IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newTypeHierarchy ( IWorkingCopy [ ] workingCopies , IProgressMonitor monitor ) throws JavaModelException { } public ITypeHierarchy newTypeHierarchy ( WorkingCopyOwner owner , IProgressMonitor monitor ) throws JavaModelException { } public String [ ] [ ] resolveType ( String typeName ) throws JavaModelException { } public String [ ] [ ] resolveType ( String typeName , WorkingCopyOwner owner ) throws JavaModelException { } protected void toStringInfo ( int tab , StringBuffer buffer , Object info ) { } }

Fix:
if ( cu . isPrimary ( ) )