Buggy code:
protected IJavaElement [ ] elementsToProcess ; protected IJavaElement [ ] parentElements ; protected static IJavaElement [ ] NO_ELEMENTS = new IJavaElement [ ] { } ; protected IJavaElement [ ] resultElements = JavaModelOperation . NO_ELEMENTS ; public IProgressMonitor progressMonitor = null ; protected boolean isNested = false ; protected boolean force = false ; protected static ThreadLocal operationStacks = new ThreadLocal ( ) ; protected JavaModelOperation ( ) { } protected JavaModelOperation ( IJavaElement [ ] elements ) { } protected JavaModelOperation ( IJavaElement [ ] elementsToProcess , IJavaElement [ ] parentElements ) { } protected JavaModelOperation ( IJavaElement [ ] elementsToProcess , IJavaElement [ ] parentElements , boolean force ) { } protected JavaModelOperation ( IJavaElement [ ] elements , boolean force ) { } protected JavaModelOperation ( IJavaElement element ) { } protected JavaModelOperation ( IJavaElement element , boolean force ) { } protected void addAction ( JavaModelOperation . IPostAction action ) { } protected void addDelta ( IJavaElementDelta delta ) { } protected void addReconcileDelta ( ICompilationUnit workingCopy , IJavaElementDelta delta ) { } protected void removeReconcileDelta ( ICompilationUnit workingCopy ) { } public void beginTask ( String name , int totalWork ) { } protected boolean canModifyRoots ( ) { } protected void checkCanceled ( ) { } protected IJavaModelStatus commonVerify ( ) { } protected void copyResources ( IResource [ ] resources , IPath destinationPath ) throws JavaModelException { } protected void createFile ( IContainer folder , String name , InputStream contents , boolean forceFlag ) throws JavaModelException { } protected void createFolder ( IContainer parentFolder , String name , boolean forceFlag ) throws JavaModelException { } protected void deleteEmptyPackageFragment ( IPackageFragment fragment , boolean forceFlag , IResource rootResource ) throws JavaModelException { } protected void deleteResource ( IResource resource , int flags ) throws JavaModelException { } protected void deleteResources ( IResource [ ] resources , boolean forceFlag ) throws JavaModelException { } public void done ( ) { } protected boolean equalsOneOf ( IPath path , IPath [ ] otherPaths ) { } public void executeNestedOperation ( JavaModelOperation operation , int subWorkAmount ) throws JavaModelException { } protected abstract void executeOperation ( ) throws JavaModelException { } protected static Object getAttribute ( Object key ) { } protected ICompilationUnit getCompilationUnitFor ( IJavaElement element ) { } protected static ArrayList getCurrentOperationStack ( ) { } protected IDocument getDocument ( ICompilationUnit cu ) throws JavaModelException { } protected IJavaElement [ ] getElementsToProcess ( ) { } protected IJavaElement getElementToProcess ( ) { } public IJavaModel getJavaModel ( ) { } protected IPath [ ] getNestedFolders ( IPackageFragmentRoot root ) throws JavaModelException { } protected IJavaElement getParentElement ( ) { } protected IJavaElement [ ] getParentElements ( ) { } public IJavaElement [ ] getResultElements ( ) { } protected ISchedulingRule getSchedulingRule ( ) { } protected IProgressMonitor getSubProgressMonitor ( int workAmount ) { } public boolean hasModifiedResource ( ) { } public void internalWorked ( double work ) { } public boolean isCanceled ( ) { } public boolean isReadOnly ( ) { } protected boolean isTopLevelOperation ( ) { } protected int firstActionWithID ( String id , int start ) { } protected void moveResources ( IResource [ ] resources , IPath destinationPath ) throws JavaModelException { } public JavaElementDelta newJavaElementDelta ( ) { } protected JavaModelOperation popOperation ( ) { } protected void postAction ( JavaModelOperation . IPostAction action , int insertionMode ) { } protected boolean prefixesOneOf ( IPath path , IPath [ ] otherPaths ) { } protected void pushOperation ( JavaModelOperation operation ) { } protected void removeAllPostAction ( String actionID ) { } public void run ( IProgressMonitor monitor ) throws CoreException { JavaModelManager manager = JavaModelManager . getJavaModelManager ( ) ; DeltaProcessor deltaProcessor = manager . getDeltaProcessor ( ) ; int previousDeltaCount = deltaProcessor . javaModelDeltas . size ( ) ; try { progressMonitor = monitor ; pushOperation ( this ) ; try { if ( canModifyRoots ( ) ) { <START_BUG> JavaModelManager . getJavaModelManager ( ) . deltaState . initializeRoots ( ) ; <END_BUG> } executeOperation ( ) ; } finally { if ( this . isTopLevelOperation ( ) ) { this . runPostActions ( ) ; } } } finally { try { deltaProcessor = manager . getDeltaProcessor ( ) ; for ( int i = previousDeltaCount , size = deltaProcessor . javaModelDeltas . size ( ) ; i < size ; i ++ ) { deltaProcessor . updateJavaModel ( ( ( IJavaElementDelta ) ( deltaProcessor . javaModelDeltas . get ( i ) ) ) ) ; } for ( int i = 0 , length = this . resultElements . length ; i < length ; i ++ ) { IJavaElement element = this . resultElements [ i ] ; Openable openable = ( ( Openable ) ( element . getOpenable ( ) ) ) ; if ( ( ! ( openable instanceof CompilationUnit ) ) || ( ! ( ( ( CompilationUnit ) ( openable ) ) . isWorkingCopy ( ) ) ) ) { ( ( JavaElement ) ( openable . getParent ( ) ) ) . close ( ) ; } switch ( element . getElementType ( ) ) { case IJavaElement . PACKAGE_FRAGMENT_ROOT : case IJavaElement . PACKAGE_FRAGMENT : deltaProcessor . projectCachesToReset . add ( element . getJavaProject ( ) ) ; break ; } } deltaProcessor . resetProjectCaches ( ) ; if ( this . isTopLevelOperation ( ) ) { if ( ( ( ( deltaProcessor . javaModelDeltas . size ( ) ) > previousDeltaCount ) || ( ! ( deltaProcessor . reconcileDeltas . isEmpty ( ) ) ) ) && ( ! ( this . hasModifiedResource ( ) ) ) ) { deltaProcessor . fire ( null , DeltaProcessor . DEFAULT_CHANGE_EVENT ) ; } } } finally { popOperation ( ) ; } } } public void runOperation ( IProgressMonitor monitor ) throws JavaModelException { } protected void runPostActions ( ) throws JavaModelException { }

Fix:
JavaModelManager . getDeltaState ( ) . initializeRoots ( ) ;