Buggy code:
public class NameLookup { public static final int ACCEPT_CLASSES = 2 ; public static final int ACCEPT_INTERFACES = 4 ; protected IPackageFragmentRoot [ ] fPackageFragmentRoots = null ; protected Hashtable fPackageFragments ; protected SingleTypeRequestor fgSingleTypeRequestor = new SingleTypeRequestor ( ) ; protected JavaElementRequestor fgJavaElementRequestor = new JavaElementRequestor ( ) ; protected IWorkspace workspace ; public NameLookup ( IJavaProject project ) throws JavaModelException { } protected boolean acceptType ( IType type , int acceptFlags ) { } private void configureFromProject ( IJavaProject project ) throws JavaModelException { workspace = project . getJavaModel ( ) . getWorkspace ( ) ; fPackageFragmentRoots = ( ( JavaProject ) ( project ) ) . getAllPackageFragmentRoots ( ) ; fPackageFragments = new Hashtable ( ) ; <START_BUG> IPackageFragment [ ] frags = ( ( JavaProject ) ( project ) ) . getAllPackageFragments ( ) ; <END_BUG> for ( int i = 0 ; i < ( frags . length ) ; i ++ ) { IPackageFragment fragment = frags [ i ] ; IPackageFragment [ ] entry = ( ( IPackageFragment [ ] ) ( fPackageFragments . get ( fragment . getElementName ( ) ) ) ) ; if ( entry == null ) { entry = new IPackageFragment [ 1 ] ; entry [ 0 ] = fragment ; fPackageFragments . put ( fragment . getElementName ( ) , entry ) ; } else { IPackageFragment [ ] copy = new IPackageFragment [ ( entry . length ) + 1 ] ; System . arraycopy ( entry , 0 , copy , 0 , entry . length ) ; copy [ entry . length ] = fragment ; fPackageFragments . put ( fragment . getElementName ( ) , copy ) ; } } } private void findAllTypes ( String prefix , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } public ICompilationUnit findCompilationUnit ( String qualifiedTypeName ) { } public IPackageFragment findPackageFragment ( IPath path ) { } public IPackageFragment [ ] findPackageFragments ( String name , boolean partialMatch ) { } public IType findType ( String typeName , String packageName , boolean partialMatch , int acceptFlags ) { } public IType findType ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags ) { } public IType findType ( String name , boolean partialMatch , int acceptFlags ) { } protected boolean nameMatches ( String searchName , IJavaElement element , boolean partialMatch ) { } public void seekPackageFragments ( String name , boolean partialMatch , IJavaElementRequestor requestor ) { } public void seekTypes ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } protected void seekTypesInBinaryPackage ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } protected void seekTypesInSourcePackage ( String name , IPackageFragment pkg , boolean partialMatch , int acceptFlags , IJavaElementRequestor requestor ) { } protected void seekQualifiedMemberTypes ( String qualifiedName , IType type , boolean partialMatch , IJavaElementRequestor requestor , int acceptFlags ) { } }

Fix:
IPackageFragment [ ] frags = ( ( JavaProject ) ( project ) ) . getPackageFragmentsInRoots ( fPackageFragmentRoots ) ;