Buggy code:
protected void generateClasspathChangeDeltas ( IClasspathEntry [ ] oldResolvedPath , IClasspathEntry [ ] newResolvedPath , JavaModelManager manager , final JavaProject project ) { boolean needToUpdateDependents = false ; JavaElementDelta delta = new JavaElementDelta ( getJavaModel ( ) ) ; boolean hasDelta = false ; int oldLength = oldResolvedPath . length ; int newLength = newResolvedPath . length ; final IndexManager indexManager = manager . getIndexManager ( ) ; Map oldRoots = null ; IPackageFragmentRoot [ ] roots = null ; if ( project . isOpen ( ) ) { try { roots = project . getPackageFragmentRoots ( ) ; } catch ( JavaModelException e ) { } } else { Map allRemovedRoots ; if ( ( allRemovedRoots = manager . deltaProcessor . removedRoots ) != null ) { roots = ( ( IPackageFragmentRoot [ ] ) ( allRemovedRoots . get ( project ) ) ) ; } } if ( roots != null ) { oldRoots = new HashMap ( ) ; for ( int i = 0 ; i < ( roots . length ) ; i ++ ) { IPackageFragmentRoot root = roots [ i ] ; oldRoots . put ( root . getPath ( ) , root ) ; } } for ( int i = 0 ; i < oldLength ; i ++ ) { int index = classpathContains ( newResolvedPath , oldResolvedPath [ i ] ) ; if ( index == ( - 1 ) ) { if ( ( oldResolvedPath [ i ] . getEntryKind ( ) ) == ( IClasspathEntry . CPE_PROJECT ) ) { needToUpdateDependents = true ; this . needCycleCheck = true ; continue ; } IPackageFragmentRoot [ ] pkgFragmentRoots = null ; if ( oldRoots != null ) { IPackageFragmentRoot oldRoot = ( ( IPackageFragmentRoot ) ( oldRoots . get ( oldResolvedPath [ i ] . getPath ( ) ) ) ) ; if ( oldRoot != null ) { pkgFragmentRoots = new IPackageFragmentRoot [ ] { oldRoot } ; } } if ( pkgFragmentRoots == null ) { try { ObjectVector accumulatedRoots = new ObjectVector ( ) ; HashSet rootIDs = new HashSet ( 5 ) ; rootIDs . add ( project . rootID ( ) ) ; project . computePackageFragmentRoots ( oldResolvedPath [ i ] , accumulatedRoots , rootIDs , true , false , false ) ; pkgFragmentRoots = new IPackageFragmentRoot [ accumulatedRoots . size ( ) ] ; accumulatedRoots . copyInto ( pkgFragmentRoots ) ; } catch ( JavaModelException e ) { pkgFragmentRoots = new IPackageFragmentRoot [ ] { } ; } } addClasspathDeltas ( pkgFragmentRoots , IJavaElementDelta . F_REMOVED_FROM_CLASSPATH , delta ) ; int changeKind = oldResolvedPath [ i ] . getEntryKind ( ) ; needToUpdateDependents |= ( changeKind == ( IClasspathEntry . CPE_SOURCE ) ) || ( oldResolvedPath [ i ] . isExported ( ) ) ; if ( ( indexManager != null ) && ( changeKind == ( IClasspathEntry . CPE_SOURCE ) ) ) { final IPath path = oldResolvedPath [ i ] . getPath ( ) ; postAction ( new JavaModelOperation . IPostAction ( ) { public String getID ( ) { return path . toString ( ) ; } public void run ( ) throws JavaModelException { indexManager . removeSourceFolderFromIndex ( project , path ) ; } } , JavaModelOperation . REMOVEALL_APPEND ) ; } hasDelta = true ; } else { if ( ( oldResolvedPath [ i ] . getEntryKind ( ) ) == ( IClasspathEntry . CPE_PROJECT ) ) { this . needCycleCheck |= ( oldResolvedPath [ i ] . isExported ( ) ) != ( newResolvedPath [ index ] . isExported ( ) ) ; continue ; } needToUpdateDependents |= ( oldResolvedPath [ i ] . isExported ( ) ) != ( newResolvedPath [ index ] . isExported ( ) ) ; if ( index != i ) { <START_BUG> addClasspathDeltas ( project . computePackageFragmentRoots ( oldResolvedPath [ i ] ) , IJavaElementDelta . F_CLASSPATH_REORDER , delta ) ; <END_BUG> int changeKind = oldResolvedPath [ i ] . getEntryKind ( ) ; needToUpdateDependents |= changeKind == ( IClasspathEntry . CPE_SOURCE ) ; hasDelta = true ; } IPath newSourcePath = newResolvedPath [ index ] . getSourceAttachmentPath ( ) ; int sourceAttachmentFlags = this . getSourceAttachmentDeltaFlag ( oldResolvedPath [ i ] . getSourceAttachmentPath ( ) , newSourcePath , null ) ; int sourceAttachmentRootFlags = this . getSourceAttachmentDeltaFlag ( oldResolvedPath [ i ] . getSourceAttachmentRootPath ( ) , newResolvedPath [ index ] . getSourceAttachmentRootPath ( ) , newSourcePath ) ; int flags = sourceAttachmentFlags | sourceAttachmentRootFlags ; if ( flags != 0 ) { addClasspathDeltas ( project . computePackageFragmentRoots ( oldResolvedPath [ i ] ) , flags , delta ) ; hasDelta = true ; } } } for ( int i = 0 ; i < newLength ; i ++ ) { int index = classpathContains ( oldResolvedPath , newResolvedPath [ i ] ) ; if ( index == ( - 1 ) ) { if ( ( newResolvedPath [ i ] . getEntryKind ( ) ) == ( IClasspathEntry . CPE_PROJECT ) ) { needToUpdateDependents = true ; this . needCycleCheck = true ; continue ; } addClasspathDeltas ( project . computePackageFragmentRoots ( newResolvedPath [ i ] ) , IJavaElementDelta . F_ADDED_TO_CLASSPATH , delta ) ; int changeKind = newResolvedPath [ i ] . getEntryKind ( ) ; if ( indexManager != null ) { switch ( changeKind ) { case IClasspathEntry . CPE_LIBRARY : boolean pathHasChanged = true ; final IPath newPath = newResolvedPath [ i ] . getPath ( ) ; for ( int j = 0 ; j < oldLength ; j ++ ) { IClasspathEntry oldEntry = oldResolvedPath [ j ] ; if ( oldEntry . getPath ( ) . equals ( newPath ) ) { pathHasChanged = false ; break ; } } if ( pathHasChanged ) { postAction ( new JavaModelOperation . IPostAction ( ) { public String getID ( ) { return newPath . toString ( ) ;

Fix:
addClasspathDeltas ( project . computePackageFragmentRoots ( oldResolvedPath [ i ] ) , IJavaElementDelta . F_REORDER , delta ) ;