### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java,v
retrieving revision 1.153
diff -u -r1.153 SetClasspathOperation.java
--- model/org/eclipse/jdt/internal/core/SetClasspathOperation.java 27 May 2008 23:40:18 -0000 1.153
+++ model/org/eclipse/jdt/internal/core/SetClasspathOperation.java 6 Feb 2009 11:35:03 -0000
@@ -10,7 +10,11 @@
*******************************************************************************/
package org.eclipse.jdt.internal.core;
+import org.eclipse.core.resources.IResourceRuleFactory;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelStatus;
@@ -64,6 +68,20 @@
done();
}
}
+
+ protected ISchedulingRule getSchedulingRule() {
+ if (this.canChangeResources) {
+ IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
+ return new MultiRule(new ISchedulingRule[] {
+ // use project modification rule as this is needed to create the .classpath file if it doesn't exist yet, or to update project references
+ ruleFactory.modifyRule(this.project.getProject()),
+
+ // and external project modification rule in case the external folders are modified
+ ruleFactory.modifyRule(JavaModelManager.getExternalManager().getExternalFoldersProject())
+ });
+ }
+ return super.getSchedulingRule();
+ }
public String toString(){
StringBuffer buffer = new StringBuffer(20);
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.397.2.4
diff -u -r1.397.2.4 JavaModelManager.java
--- model/org/eclipse/jdt/internal/core/JavaModelManager.java 8 Dec 2008 14:41:23 -0000 1.397.2.4
+++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 6 Feb 2009 11:35:03 -0000
@@ -1188,41 +1188,19 @@
return buffer.toString();
}
- public boolean writeAndCacheClasspath(final JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException {
- final boolean[] result = new boolean[1];
+ public boolean writeAndCacheClasspath(JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException {
try {
- // use a workspace runnable so that the notification of .classpath file change is done outside the synchronized block (to avoid deadlocks)
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- // ensure that the writing of the .classpath file and the caching in memory are synchronized (see also readAnCacheClasspath which is synchronized)
- try {
- PerProjectInfo.this.writtingRawClasspath = true;
- synchronized (PerProjectInfo.this) {
- if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) {
- result[0] = false;
- return;
- }
- // store new raw classpath, new output and new status, and null out resolved info
- setClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null);
- result[0] = true;
- }
- } finally {
- PerProjectInfo.this.writtingRawClasspath = false;
- }
- }
- },
- workspace.getRuleFactory().modifyRule(this.project), // use project modification rule as this is needed to create the .classpath file if it doesn't exist yet
- IWorkspace.AVOID_UPDATE,
- null);
- } catch (JavaModelException e) {
- // rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
- throw e;
- } catch (CoreException e) {
- // rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
- throw new JavaModelException(e);
+ this.writtingRawClasspath = true;
+ // write .classpath
+ if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) {
+ return false;
+ }
+ // store new raw classpath, new output and new status, and null out resolved info
+ setClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null);
+ } finally {
+ this.writtingRawClasspath = false;
}
- return result[0];
+ return true;
}
}