Buggy code:
public class JavaBuilder extends IncrementalProjectBuilder { IProject currentProject ; JavaProject javaProject ; IWorkspaceRoot workspaceRoot ; CompilationParticipant [ ] participants ; NameEnvironment nameEnvironment ; SimpleLookupTable binaryLocationsPerProject ; public State lastState ; BuildNotifier notifier ; char [ ] [ ] extraResourceFileFilters ; String [ ] extraResourceFolderFilters ; public static final String SOURCE_ID = "JDT" ; public static boolean DEBUG = false ; public static boolean SHOW_STATS = false ; static ArrayList builtProjects = null ; public static IMarker [ ] getProblemsFor ( IResource resource ) { } public static IMarker [ ] getTasksFor ( IResource resource ) { } public static void buildStarting ( ) { } public static void buildFinished ( ) { } public static void removeProblemsFor ( IResource resource ) { } public static void removeTasksFor ( IResource resource ) { } public static void removeProblemsAndTasksFor ( IResource resource ) { } public static State readState ( IProject project , DataInputStream in ) throws IOException { } public static void writeState ( Object state , DataOutputStream out ) throws IOException { } protected IProject [ ] build ( int kind , Map ignored , IProgressMonitor monitor ) throws CoreException { } private void buildAll ( ) { } private void buildDeltas ( SimpleLookupTable deltas ) { } protected void clean ( IProgressMonitor monitor ) throws CoreException { } private void createInconsistentBuildMarker ( CoreException coreException ) throws CoreException { } private void cleanup ( ) { } private void clearLastState ( ) { } boolean filterExtraResource ( IResource resource ) { } private SimpleLookupTable findDeltas ( ) { } public State getLastState ( IProject project ) { } private IProject [ ] getRequiredProjects ( boolean includeBinaryPrerequisites ) { if ( ( ( this . javaProject ) == null ) || ( ( this . workspaceRoot ) == null ) ) return new IProject [ 0 ] ; ArrayList projects = new ArrayList ( ) ; ExternalFoldersManager externalFoldersManager = JavaModelManager . getExternalManager ( ) ; try { IClasspathEntry [ ] entries = this . javaProject . getExpandedClasspath ( ) ; for ( int i = 0 , l = entries . length ; i < l ; i ++ ) { IClasspathEntry entry = entries [ i ] ; IPath path = entry . getPath ( ) ; IProject p = null ; switch ( entry . getEntryKind ( ) ) { case IClasspathEntry . CPE_PROJECT : p = this . workspaceRoot . getProject ( path . lastSegment ( ) ) ; if ( ( ( ( ClasspathEntry ) ( entry ) ) . isOptional ( ) ) && ( ! ( JavaProject . hasJavaNature ( p ) ) ) ) p = null ; break ; case IClasspathEntry . CPE_LIBRARY : <START_BUG> if ( includeBinaryPrerequisites && ( ( path . segmentCount ( ) ) > 1 ) ) { <END_BUG> IResource resource = this . workspaceRoot . findMember ( path . segment ( 0 ) ) ; if ( resource instanceof IProject ) { p = ( ( IProject ) ( resource ) ) ; } else { resource = externalFoldersManager . getFolder ( path ) ; if ( resource != null ) p = resource . getProject ( ) ; } } } if ( ( p != null ) && ( ! ( projects . contains ( p ) ) ) ) projects . add ( p ) ; } } catch ( JavaModelException e ) { return new IProject [ 0 ] ; } IProject [ ] result = new IProject [ projects . size ( ) ] ; projects . toArray ( result ) ; return result ; } boolean hasBuildpathErrors ( ) throws CoreException { } private boolean hasClasspathChanged ( ) { } private boolean hasJavaBuilder ( IProject project ) throws CoreException { } private boolean hasStructuralDelta ( ) { } private int initializeBuilder ( int kind , boolean forBuild ) throws CoreException { } private boolean isClasspathBroken ( IClasspathEntry [ ] classpath , IProject p ) throws CoreException { } private boolean isWorthBuilding ( ) throws CoreException { } void mustPropagateStructuralChanges ( ) { } private void printLocations ( ClasspathLocation [ ] newLocations , ClasspathLocation [ ] oldLocations ) { } private void recordNewState ( State state ) { } public String toString ( ) { } }

Fix:
if ( includeBinaryPrerequisites && ( ( path . segmentCount ( ) ) > 0 ) ) {