### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaModelManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java,v retrieving revision 1.430 diff -u -r1.430 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 20 Mar 2009 09:09:21 -0000 1.430 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 17 Apr 2009 16:29:22 -0000 @@ -1151,8 +1151,7 @@ protected ClasspathChange addClasspathChange() { // remember old info JavaModelManager manager = JavaModelManager.getJavaModelManager(); - DeltaProcessor deltaProcessor = manager.deltaState.getDeltaProcessor(); - ClasspathChange classpathChange = deltaProcessor.addClasspathChange(this.project, this.rawClasspath, this.outputLocation, this.resolvedClasspath); + ClasspathChange classpathChange = manager.deltaState.addClasspathChange(this.project, this.rawClasspath, this.outputLocation, this.resolvedClasspath); return classpathChange; } Index: model/org/eclipse/jdt/internal/core/DeltaProcessingState.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessingState.java,v retrieving revision 1.52 diff -u -r1.52 DeltaProcessingState.java --- model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 20 Mar 2009 09:09:21 -0000 1.52 +++ model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 17 Apr 2009 16:29:20 -0000 @@ -87,6 +87,13 @@ /* A table from file system absoulte path (String) to timestamp (Long) */ public Hashtable externalTimeStamps; + /* + * Map from IProject to ClasspathChange + * Note these changes need to be kept on the delta processing state to ensure we don't loose them + * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=271102 Java model corrupt after switching target platform) + */ + private HashMap classpathChanges = new HashMap(); + /* A table from JavaProject to ClasspathValidation */ private HashMap classpathValidations = new HashMap(); @@ -171,6 +178,32 @@ return deltaProcessor; } + public synchronized ClasspathChange addClasspathChange(IProject project, IClasspathEntry[] oldRawClasspath, IPath oldOutputLocation, IClasspathEntry[] oldResolvedClasspath) { + ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project); + if (change == null) { + change = new ClasspathChange((JavaProject) JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject(project), oldRawClasspath, oldOutputLocation, oldResolvedClasspath); + this.classpathChanges.put(project, change); + } else { + if (change.oldRawClasspath == null) + change.oldRawClasspath = oldRawClasspath; + if (change.oldOutputLocation == null) + change.oldOutputLocation = oldOutputLocation; + if (change.oldResolvedClasspath == null) + change.oldResolvedClasspath = oldResolvedClasspath; + } + return change; + } + + public synchronized ClasspathChange getClasspathChange(IProject project) { + return (ClasspathChange) this.classpathChanges.get(project); + } + + public synchronized HashMap removeAllClasspathChanges() { + HashMap result = this.classpathChanges; + this.classpathChanges = new HashMap(result.size()); + return result; + } + public synchronized ClasspathValidation addClasspathValidation(JavaProject project) { ClasspathValidation validation = (ClasspathValidation) this.classpathValidations.get(project); if (validation == null) { Index: model/org/eclipse/jdt/internal/core/DeltaProcessor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java,v retrieving revision 1.333 diff -u -r1.333 DeltaProcessor.java --- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 7 Mar 2009 00:58:57 -0000 1.333 +++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 17 Apr 2009 16:29:21 -0000 @@ -252,32 +252,11 @@ */ private SourceElementParser sourceElementParserCache; - /* - * Map from IProject to ClasspathChange - */ - public HashMap classpathChanges = new HashMap(); - public DeltaProcessor(DeltaProcessingState state, JavaModelManager manager) { this.state = state; this.manager = manager; } - public ClasspathChange addClasspathChange(IProject project, IClasspathEntry[] oldRawClasspath, IPath oldOutputLocation, IClasspathEntry[] oldResolvedClasspath) { - ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project); - if (change == null) { - change = new ClasspathChange((JavaProject) this.manager.getJavaModel().getJavaProject(project), oldRawClasspath, oldOutputLocation, oldResolvedClasspath); - this.classpathChanges.put(project, change); - } else { - if (change.oldRawClasspath == null) - change.oldRawClasspath = oldRawClasspath; - if (change.oldOutputLocation == null) - change.oldOutputLocation = oldOutputLocation; - if (change.oldResolvedClasspath == null) - change.oldResolvedClasspath = oldResolvedClasspath; - } - return change; - } - /* * Adds the dependents of the given project to the list of the projects * to update. @@ -487,12 +466,12 @@ } private void checkExternalFolderChange(IProject project, JavaProject javaProject) { - ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project); + ClasspathChange change = this.state.getClasspathChange(project); this.state.addExternalFolderChange(javaProject, change == null ? null : change.oldResolvedClasspath); } private void checkProjectReferenceChange(IProject project, JavaProject javaProject) { - ClasspathChange change = (ClasspathChange) this.classpathChanges.get(project); + ClasspathChange change = this.state.getClasspathChange(project); this.state.addProjectReferenceChange(javaProject, change == null ? null : change.oldResolvedClasspath); } @@ -1927,10 +1906,11 @@ } // generate classpath change deltas - if (this.classpathChanges.size() > 0) { + HashMap classpathChanges = this.state.removeAllClasspathChanges(); + if (classpathChanges.size() > 0) { boolean hasDelta = this.currentDelta != null; JavaElementDelta javaDelta = currentDelta(); - Iterator changes = this.classpathChanges.values().iterator(); + Iterator changes = classpathChanges.values().iterator(); while (changes.hasNext()) { ClasspathChange change = (ClasspathChange) changes.next(); int result = change.generateDelta(javaDelta); @@ -1955,7 +1935,6 @@ if (elementsToRefresh != null) { hasDelta |= createExternalArchiveDelta(elementsToRefresh, null); } - this.classpathChanges.clear(); if (!hasDelta) this.currentDelta = null; }