Buggy code:
public class IndexBasedHierarchyBuilder extends HierarchyBuilder { protected Map cuToHandle ; protected Map handleToWorkingCopy ; protected IJavaSearchScope scope ; protected Map binariesFromIndexMatches ; private static class Queue { public char [ ] [ ] names = new char [ 10 ] [ ] ; public int start = 0 ; public int end = - 1 ; public void add ( char [ ] name ) { } public char [ ] retrieve ( ) { } public String toString ( ) { } } public IndexBasedHierarchyBuilder ( TypeHierarchy hierarchy , IJavaSearchScope scope ) throws JavaModelException { } private void addInfoFromBinaryIndexMatch ( Openable handle , HierarchyBinaryType binaryType , ArrayList infos ) throws JavaModelException { } protected void addInfoFromClosedElement ( Openable handle , ArrayList infos , ArrayList units , String resourcePath ) throws JavaModelException { } private void addInfosFromType ( IType type , ArrayList infos ) throws JavaModelException { } public void build ( boolean computeSubtypes ) throws CoreException , JavaModelException { } private void buildForProject ( JavaProject project , ArrayList infos , ArrayList units , IWorkingCopy [ ] workingCopies ) throws JavaModelException { } private void buildFromPotentialSubtypes ( String [ ] allPotentialSubTypes ) { IType focusType = this . getType ( ) ; HashMap wcPaths = new HashMap ( ) ; int wcLength ; IWorkingCopy [ ] workingCopies = this . getWokingCopies ( ) ; if ( ( workingCopies != null ) && ( ( wcLength = workingCopies . length ) > 0 ) ) { String [ ] newPaths = new String [ wcLength ] ; for ( int i = 0 ; i < wcLength ; i ++ ) { IWorkingCopy workingCopy = workingCopies [ i ] ; String path = workingCopy . getOriginalElement ( ) . getPath ( ) . toString ( ) ; wcPaths . put ( path , workingCopy ) ; newPaths [ i ] = path ; } int potentialSubtypesLength = allPotentialSubTypes . length ; System . arraycopy ( allPotentialSubTypes , 0 , ( allPotentialSubTypes = new String [ potentialSubtypesLength + wcLength ] ) , 0 , potentialSubtypesLength ) ; System . arraycopy ( newPaths , 0 , allPotentialSubTypes , potentialSubtypesLength , wcLength ) ; } int length = allPotentialSubTypes . length ; Openable focusCU = ( ( Openable ) ( focusType . getCompilationUnit ( ) ) ) ; String focusPath = null ; if ( focusCU != null ) { focusPath = focusCU . getPath ( ) . toString ( ) ; if ( length > 0 ) { System . arraycopy ( allPotentialSubTypes , 0 , ( allPotentialSubTypes = new String [ length + 1 ] ) , 0 , length ) ; allPotentialSubTypes [ length ] = focusPath ; } else { allPotentialSubTypes = new String [ ] { focusPath } ; } length ++ ; } Util . sortReverseOrder ( allPotentialSubTypes ) ; ArrayList infos = new ArrayList ( ) ; ArrayList units = new ArrayList ( ) ; HandleFactory factory = new HandleFactory ( ResourcesPlugin . getWorkspace ( ) ) ; IJavaProject currentProject = null ; for ( int i = 0 ; i < length ; i ++ ) { try { String resourcePath = allPotentialSubTypes [ i ] ; if ( ( i > 0 ) && ( resourcePath . equals ( allPotentialSubTypes [ ( i - 1 ) ] ) ) ) continue ; Openable handle ; IWorkingCopy workingCopy = ( ( IWorkingCopy ) ( wcPaths . get ( resourcePath ) ) ) ; if ( workingCopy != null ) { handle = ( ( Openable ) ( workingCopy ) ) ; } else { <START_BUG> handle = ( resourcePath . equals ( focusPath ) ) ? focusCU : factory . createOpenable ( resourcePath ) ; <END_BUG> if ( handle == null ) continue ; } IJavaProject project = handle . getJavaProject ( ) ; if ( currentProject == null ) { currentProject = project ; infos = new ArrayList ( 5 ) ; units = new ArrayList ( 5 ) ; } else if ( ! ( currentProject . equals ( project ) ) ) { this . buildForProject ( ( ( JavaProject ) ( currentProject ) ) , infos , units , workingCopies ) ; currentProject = project ; infos = new ArrayList ( 5 ) ; units = new ArrayList ( 5 ) ; } this . addInfoFromElement ( handle , infos , units , resourcePath ) ; worked ( 1 ) ; } catch ( JavaModelException e ) { continue ; } } try { if ( currentProject == null ) { currentProject = focusType . getJavaProject ( ) ; this . addInfosFromType ( focusType , infos ) ; } this . buildForProject ( ( ( JavaProject ) ( currentProject ) ) , infos , units , workingCopies ) ; } catch ( JavaModelException e ) { } if ( ! ( this . hierarchy . contains ( focusType ) ) ) { try { currentProject = focusType . getJavaProject ( ) ; infos = new ArrayList ( ) ; units = new ArrayList ( ) ; this . addInfosFromType ( focusType , infos ) ; this . buildForProject ( ( ( JavaProject ) ( currentProject ) ) , infos , units , workingCopies ) ; } catch ( JavaModelException e ) { } } if ( ! ( this . hierarchy . contains ( focusType ) ) ) { this . hierarchy . addRootClass ( focusType ) ; } } protected ICompilationUnit createCompilationUnitFromPath ( Openable handle , String osPath ) throws JavaModelException { } private String [ ] determinePossibleSubTypes ( ) throws CoreException , JavaModelException { } protected IType getHandle ( IGenericType genericType ) { } public static void searchAllPossibleSubTypes ( IWorkspace workbench , IType type , IJavaSearchScope scope , final Map binariesFromIndexMatches , final IPathRequestor pathRequestor , int waitingPolicy , IProgressMonitor progressMonitor ) throws CoreException , JavaModelException { } }

Fix:
handle = ( resourcePath . equals ( focusPath ) ) ? focusCU : factory . createOpenable ( resourcePath , this . scope ) ;