Buggy code:
public class NameEnvironment implements INameEnvironment , SuffixConstants { boolean isIncrementalBuild ; ClasspathMultiDirectory [ ] sourceLocations ; ClasspathLocation [ ] binaryLocations ; String [ ] initialTypeNames ; SourceFile [ ] additionalUnits ; NameEnvironment ( IWorkspaceRoot root , JavaProject javaProject , SimpleLookupTable binaryLocationsPerProject ) throws CoreException { } public NameEnvironment ( IJavaProject javaProject ) { } private void computeClasspathLocations ( IWorkspaceRoot root , JavaProject javaProject , SimpleLookupTable binaryLocationsPerProject ) throws CoreException { <START_BUG> IClasspathEntry [ ] classpathEntries = javaProject . getExpandedClasspath ( true , true ) ; <END_BUG> IMarker cycleMarker = javaProject . getCycleMarker ( ) ; if ( cycleMarker != null ) { int severity = ( JavaCore . ERROR . equals ( javaProject . getOption ( JavaCore . CORE_CIRCULAR_CLASSPATH , true ) ) ) ? IMarker . SEVERITY_ERROR : IMarker . SEVERITY_WARNING ; if ( severity != ( ( ( Integer ) ( cycleMarker . getAttribute ( IMarker . SEVERITY ) ) ) . intValue ( ) ) ) cycleMarker . setAttribute ( IMarker . SEVERITY , severity ) ; } ArrayList sLocations = new ArrayList ( classpathEntries . length ) ; ArrayList bLocations = new ArrayList ( classpathEntries . length ) ; nextEntry : for ( int i = 0 , l = classpathEntries . length ; i < l ; i ++ ) { ClasspathEntry entry = ( ( ClasspathEntry ) ( classpathEntries [ i ] ) ) ; IPath path = entry . getPath ( ) ; Object target = JavaModel . getTarget ( root , path , true ) ; if ( target == null ) continue nextEntry ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_SOURCE : if ( ! ( target instanceof IContainer ) ) continue nextEntry ; IPath outputPath = ( ( entry . getOutputLocation ( ) ) != null ) ? entry . getOutputLocation ( ) : javaProject . getOutputLocation ( ) ; IContainer outputFolder ; if ( ( outputPath . segmentCount ( ) ) == 1 ) { outputFolder = javaProject . getProject ( ) ; } else { outputFolder = root . getFolder ( outputPath ) ; if ( ! ( outputFolder . exists ( ) ) ) createFolder ( outputFolder ) ; } sLocations . add ( ClasspathLocation . forSourceFolder ( ( ( IContainer ) ( target ) ) , outputFolder , entry . fullExclusionPatternChars ( ) ) ) ; continue nextEntry ; case IClasspathEntry . CPE_PROJECT : if ( ! ( target instanceof IProject ) ) continue nextEntry ; IProject prereqProject = ( ( IProject ) ( target ) ) ; if ( ! ( JavaProject . hasJavaNature ( prereqProject ) ) ) continue nextEntry ; JavaProject prereqJavaProject = ( ( JavaProject ) ( JavaCore . create ( prereqProject ) ) ) ; IClasspathEntry [ ] prereqClasspathEntries = prereqJavaProject . getRawClasspath ( ) ; ArrayList seen = new ArrayList ( ) ; nextPrereqEntry : for ( int j = 0 , m = prereqClasspathEntries . length ; j < m ; j ++ ) { IClasspathEntry prereqEntry = prereqClasspathEntries [ j ] ; if ( ( prereqEntry . getEntryKind ( ) ) == ( IClasspathEntry . CPE_SOURCE ) ) { Object prereqTarget = JavaModel . getTarget ( root , prereqEntry . getPath ( ) , true ) ; if ( ! ( prereqTarget instanceof IContainer ) ) continue nextPrereqEntry ; IPath prereqOutputPath = ( ( prereqEntry . getOutputLocation ( ) ) != null ) ? prereqEntry . getOutputLocation ( ) : prereqJavaProject . getOutputLocation ( ) ; IContainer binaryFolder = ( ( prereqOutputPath . segmentCount ( ) ) == 1 ) ? ( ( IContainer ) ( prereqProject ) ) : ( ( IContainer ) ( root . getFolder ( prereqOutputPath ) ) ) ; if ( ( binaryFolder . exists ( ) ) && ( ! ( seen . contains ( binaryFolder ) ) ) ) { seen . add ( binaryFolder ) ; ClasspathLocation bLocation = ClasspathLocation . forBinaryFolder ( binaryFolder , true ) ; bLocations . add ( bLocation ) ; if ( binaryLocationsPerProject != null ) { ClasspathLocation [ ] existingLocations = ( ( ClasspathLocation [ ] ) ( binaryLocationsPerProject . get ( prereqProject ) ) ) ; if ( existingLocations == null ) { existingLocations = new ClasspathLocation [ ] { bLocation } ; } else { int size = existingLocations . length ; System . arraycopy ( existingLocations , 0 , ( existingLocations = new ClasspathLocation [ size + 1 ] ) , 0 , size ) ; existingLocations [ size ] = bLocation ; } binaryLocationsPerProject . put ( prereqProject , existingLocations ) ; } } } } continue nextEntry ; case IClasspathEntry . CPE_LIBRARY : if ( target instanceof IResource ) { IResource resource = ( ( IResource ) ( target ) ) ; ClasspathLocation bLocation = null ; if ( resource instanceof IFile ) { if ( ! ( Util . isArchiveFileName ( path . lastSegment ( ) ) ) ) continue nextEntry ; bLocation = ClasspathLocation . forLibrary ( ( ( IFile ) ( resource ) ) ) ; } else if ( resource instanceof IContainer ) { bLocation = ClasspathLocation . forBinaryFolder ( ( ( IContainer ) ( target ) ) , false ) ; } bLocations . add ( bLocation ) ; if ( binaryLocationsPerProject != null ) { IProject p = resource . getProject ( ) ; ClasspathLocation [ ] existingLocations = ( ( ClasspathLocation [ ] ) ( binaryLocationsPerProject . get ( p ) ) ) ; if ( existingLocations == null ) { existingLocations = new ClasspathLocation [ ] { bLocation } ; } else { int size = existingLocations . length ; System . arraycopy ( existingLocations , 0 , ( existingLocations = new ClasspathLocation [ size + 1 ] ) , 0 , size ) ; existingLocations [ size ] = bLocation ; } binaryLocationsPerProject . put ( p , existingLocations ) ; } }

Fix:
IClasspathEntry [ ] classpathEntries = javaProject . getExpandedClasspath ( true , true , preferredClasspaths , preferredOutputs ) ;