Buggy code:
private static final String ZIP_ACCESS_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//zipaccess" ; private static final String DELTA_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//javadelta" ; private static final String HIERARCHY_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//hierarchy" ; private static final String POST_ACTION_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//postaction" ; private static final String BUILDER_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//builder" ; private static final String COMPLETION_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//completion" ; private static final String SELECTION_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//selection" ; private static final String SEARCH_DEBUG = ( JavaCore . PLUGIN_ID ) + "//debug//search" ; public static final ICompilationUnit [ ] NoWorkingCopy = new ICompilationUnit [ 0 ] ; public static boolean conflictsWithOutputLocation ( IPath folderPath , JavaProject project ) { } public static IClasspathContainer containerGet ( IJavaProject project , IPath containerPath ) { } public static void containerPut ( IJavaProject project , IPath containerPath , IClasspathContainer container ) { } public static IJavaElement create ( IResource resource , IJavaProject project , WorkingCopyOwner owner ) { } public static IJavaElement create ( IFile file , IJavaProject project , WorkingCopyOwner owner ) { } public static IJavaElement create ( IFolder folder , IJavaProject project ) { } public static IClassFile createClassFileFrom ( IFile file , IJavaProject project ) { } public static ICompilationUnit createCompilationUnitFrom ( IFile file , IJavaProject project , WorkingCopyOwner owner ) { } public static IPackageFragmentRoot createJarPackageFragmentRootFrom ( IFile file , IJavaProject project ) { } public static IJavaElement determineIfOnClasspath ( IResource resource , IJavaProject project ) { } private static final JavaModelManager Manager = new JavaModelManager ( ) ; protected JavaModelCache cache = new JavaModelCache ( ) ; private PerThreadObject temporaryCache = new PerThreadObject ( ) ; protected Map elementsOutOfSynchWithBuffers = new HashMap ( 11 ) ; public final DeltaProcessingState deltaState = new DeltaProcessingState ( ) ; public IndexManager indexManager = new IndexManager ( ) ; protected Map perProjectInfos = new HashMap ( 5 ) ; protected Map perWorkingCopyInfos = new HashMap ( 5 ) ; protected WeakHashMap searchScopes = new WeakHashMap ( ) ; public static class PerProjectInfo { public IProject project ; public Object savedState ; public boolean triedRead ; public IClasspathEntry [ ] rawClasspath ; public IClasspathEntry [ ] resolvedClasspath ; public Map resolvedPathToRawEntries ; public IPath outputLocation ; public Preferences preferences ; public PerProjectInfo ( IProject project ) { } public synchronized void updateClasspathInformation ( IClasspathEntry [ ] newRawClasspath ) { } } public static class PerWorkingCopyInfo implements IProblemRequestor { int useCount = 0 ; IProblemRequestor problemRequestor ; ICompilationUnit workingCopy ; public PerWorkingCopyInfo ( ICompilationUnit workingCopy , IProblemRequestor problemRequestor ) { } public void acceptProblem ( IProblem problem ) { } public void beginReporting ( ) { } public void endReporting ( ) { } public ICompilationUnit getWorkingCopy ( ) { } public boolean isActive ( ) { } } public static boolean VERBOSE = false ; public static boolean CP_RESOLVE_VERBOSE = false ; public static boolean ZIP_ACCESS_VERBOSE = false ; private PerThreadObject zipFiles = new PerThreadObject ( ) ; public static class PluginPreferencesListener implements Preferences . IPropertyChangeListener { public void propertyChange ( Preferences . PropertyChangeEvent event ) { } } private JavaModelManager ( ) { } public void cacheZipFiles ( ) { } public void closeZipFile ( ZipFile zipFile ) { } public void configurePluginDebugOptions ( ) { } public int discardPerWorkingCopyInfo ( CompilationUnit workingCopy ) throws JavaModelException { synchronized ( perWorkingCopyInfos ) { WorkingCopyOwner owner = workingCopy . owner ; Map pathToPerWorkingCopyInfos = ( ( Map ) ( this . perWorkingCopyInfos . get ( owner ) ) ) ; if ( pathToPerWorkingCopyInfos == null ) return - 1 ; IPath path = workingCopy . getPath ( ) ; JavaModelManager . PerWorkingCopyInfo info = ( ( JavaModelManager . PerWorkingCopyInfo ) ( pathToPerWorkingCopyInfos . get ( path ) ) ) ; if ( info == null ) return - 1 ; if ( ( -- ( info . useCount ) ) == 0 ) { JavaElementDeltaBuilder deltaBuilder = null ; <START_BUG> if ( ( workingCopy . owner ) == ( DefaultWorkingCopyOwner . PRIMARY ) ) { <END_BUG> deltaBuilder = new JavaElementDeltaBuilder ( workingCopy ) ; } IJavaElement originalElement = workingCopy . getPrimary ( ) ; pathToPerWorkingCopyInfos . remove ( path ) ; if ( pathToPerWorkingCopyInfos . isEmpty ( ) ) { this . perWorkingCopyInfos . remove ( owner ) ; } removeInfoAndChildren ( workingCopy ) ; workingCopy . closeBuffer ( ) ; if ( ! ( workingCopy . getParent ( ) . exists ( ) ) ) { ( ( CompilationUnit ) ( originalElement ) ) . close ( ) ; } if ( deltaBuilder != null ) { deltaBuilder . buildDeltas ( ) ; if ( ( ( deltaBuilder . delta ) != null ) && ( ( deltaBuilder . delta . getAffectedChildren ( ) . length ) > 0 ) ) { getDeltaProcessor ( ) . registerJavaModelDelta ( deltaBuilder . delta ) ; } } } return info . useCount ; } } public void doneSaving ( ISaveContext context ) { } public void flushZipFiles ( ) { } public DeltaProcessor getDeltaProcessor ( ) { } protected Map getElementsOutOfSynchWithBuffers ( ) { } public IndexManager getIndexManager ( ) { } public synchronized Object getInfo ( IJavaElement element ) { } public final JavaModel getJavaModel ( ) { } public static final JavaModelManager getJavaModelManager ( ) { } public Object getLastBuiltState ( IProject project , IProgressMonitor monitor ) { } public JavaModelManager . PerProjectInfo getPerProjectInfo ( IProject project , boolean create ) { } public JavaModelManager . PerProjectInfo getPerProjectInfoCheckExistence ( IProject project ) throws JavaModelException { } public JavaModelManager . PerWorkingCopyInfo getPerWorkingCopyInfo ( CompilationUnit workingCopy , IPath path , boolean create , boolean recordUsage , IProblemRequestor problemRequestor ) { } public HashMap getTemporaryCache ( ) { } public static String [ ] getRegisteredVariableNames ( ) { } public static String [ ] getRegisteredContainerIDs ( ) { }

Fix:
if ( workingCopy . isPrimary ( ) ) {