View | Details | Raw Unified | Return to bug 249930 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SetClasspathOperation.java (+18 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.core.resources.IResourceRuleFactory;
14
import org.eclipse.core.resources.ResourcesPlugin;
13
import org.eclipse.core.runtime.IPath;
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.jobs.ISchedulingRule;
17
import org.eclipse.core.runtime.jobs.MultiRule;
14
import org.eclipse.jdt.core.IClasspathEntry;
18
import org.eclipse.jdt.core.IClasspathEntry;
15
import org.eclipse.jdt.core.IJavaElement;
19
import org.eclipse.jdt.core.IJavaElement;
16
import org.eclipse.jdt.core.IJavaModelStatus;
20
import org.eclipse.jdt.core.IJavaModelStatus;
Lines 64-69 Link Here
64
			done();
68
			done();
65
		}
69
		}
66
	}
70
	}
71
	
72
	protected ISchedulingRule getSchedulingRule() {
73
		if (this.canChangeResources) {
74
			IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
75
			return new MultiRule(new ISchedulingRule[] {
76
				// use project modification rule as this is needed to create the .classpath file if it doesn't exist yet, or to update project references
77
				ruleFactory.modifyRule(this.project.getProject()),
78
				
79
				// and external project modification rule in case the external folders are modified
80
				ruleFactory.modifyRule(JavaModelManager.getExternalManager().getExternalFoldersProject())
81
			});
82
		}
83
		return super.getSchedulingRule();
84
	}
67
85
68
	public String toString(){
86
	public String toString(){
69
		StringBuffer buffer = new StringBuffer(20);
87
		StringBuffer buffer = new StringBuffer(20);
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-33 / +11 lines)
Lines 1188-1228 Link Here
1188
			return buffer.toString();
1188
			return buffer.toString();
1189
		}
1189
		}
1190
		
1190
		
1191
		public boolean writeAndCacheClasspath(final JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException {
1191
		public boolean writeAndCacheClasspath(JavaProject javaProject, final IClasspathEntry[] newRawClasspath, final IPath newOutputLocation) throws JavaModelException {
1192
			final boolean[] result = new boolean[1];
1193
			try {
1192
			try {
1194
				// use a workspace runnable so that the notification of .classpath file change is done outside the synchronized block (to avoid deadlocks)
1193
				this.writtingRawClasspath = true;
1195
				IWorkspace workspace = 	ResourcesPlugin.getWorkspace();
1194
				// write .classpath
1196
				workspace.run(new IWorkspaceRunnable() {
1195
				if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) {
1197
					public void run(IProgressMonitor monitor) throws CoreException {
1196
					return false;
1198
						// ensure that the writing of the .classpath file and the caching in memory are synchronized (see also readAnCacheClasspath which is synchronized)
1197
				}
1199
						try {
1198
				// store new raw classpath, new output and new status, and null out resolved info
1200
							PerProjectInfo.this.writtingRawClasspath = true;
1199
				setClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null);
1201
							synchronized (PerProjectInfo.this) {
1200
			} finally {
1202
								if (!javaProject.writeFileEntries(newRawClasspath, newOutputLocation)) {
1201
				this.writtingRawClasspath = false;
1203
									result[0] = false;
1204
									return;
1205
								}
1206
								// store new raw classpath, new output and new status, and null out resolved info
1207
								setClasspath(newRawClasspath, newOutputLocation, JavaModelStatus.VERIFIED_OK, null, null, null, null);
1208
								result[0] = true;
1209
							}
1210
						} finally {
1211
							PerProjectInfo.this.writtingRawClasspath = false;
1212
						}
1213
					}
1214
				}, 
1215
				workspace.getRuleFactory().modifyRule(this.project), // use project modification rule as this is needed to create the .classpath file if it doesn't exist yet
1216
				IWorkspace.AVOID_UPDATE,
1217
				null);
1218
			} catch (JavaModelException e) {
1219
			    // rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
1220
				throw e;
1221
			} catch (CoreException e) {
1222
			    // rethrow exception (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=245576 )
1223
				throw new JavaModelException(e);
1224
			}
1202
			}
1225
			return result[0];
1203
			return true;
1226
		}
1204
		}
1227
	}
1205
	}
1228
	
1206
	

Return to bug 249930