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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ChangeClasspathOperation.java (+6 lines)
Lines 10-15 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.ResourcesPlugin;
13
import org.eclipse.core.runtime.jobs.ISchedulingRule;
14
import org.eclipse.core.runtime.jobs.ISchedulingRule;
14
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.core.IJavaElement;
15
import org.eclipse.jdt.core.JavaModelException;
16
import org.eclipse.jdt.core.JavaModelException;
Lines 43-48 Link Here
43
		DeltaProcessor deltaProcessor = state.getDeltaProcessor();
44
		DeltaProcessor deltaProcessor = state.getDeltaProcessor();
44
		ClasspathChange change = (ClasspathChange) deltaProcessor.classpathChanges.get(project.getProject());
45
		ClasspathChange change = (ClasspathChange) deltaProcessor.classpathChanges.get(project.getProject());
45
		if (this.canChangeResources) {
46
		if (this.canChangeResources) {
47
			// workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=177922
48
			if (isTopLevelOperation() && !ResourcesPlugin.getWorkspace().isTreeLocked()) {
49
				new ClasspathValidation(project).validate();
50
			}
51
				
46
			// delta, indexing and classpath markers are going to be created by the delta processor 
52
			// delta, indexing and classpath markers are going to be created by the delta processor 
47
			// while handling the .classpath file change
53
			// while handling the .classpath file change
48
54
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+34 lines)
Lines 3715-3720 Link Here
3715
}
3715
}
3716
3716
3717
/*
3717
/*
3718
 * Ensures that renaming a .jar file and updating the classpath in a PRE_BUILD event doesn't leave markers
3719
 * (regression test for bug 177922 FlexibleProjectContainer refresh logic sporadically leaves project with "missing library" error on rename/delete)
3720
 */
3721
public void testRenameJar() throws CoreException {
3722
	IResourceChangeListener listener = null;
3723
	try {
3724
		final IJavaProject p = createJavaProject("P", new String[0], new String[] {"/P/lib/test1.jar"}, "");
3725
		createFolder("/P/lib");
3726
		createFile("/P/lib/test1.jar", "");
3727
		// at this point no markers exist
3728
		
3729
		// register a listener that updates the classpath in a PRE_BUILD event
3730
		listener = new IResourceChangeListener(){
3731
			public void resourceChanged(IResourceChangeEvent event) {
3732
				try {
3733
					p.setRawClasspath(new IClasspathEntry[] {JavaCore.newLibraryEntry(new Path("/P/lib/test2.jar"), null, null)}, null);
3734
				} catch (JavaModelException e) {
3735
					e.printStackTrace();
3736
				}
3737
			}
3738
		};
3739
		getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.PRE_BUILD);
3740
		
3741
		// rename .jar
3742
		getFile("/P/lib/test1.jar").move(new Path("/P/lib/test2.jar"), false, null);
3743
		assertMarkers("Unexpected markers", "", p);
3744
	} finally {
3745
		if (listener != null)
3746
			getWorkspace().removeResourceChangeListener(listener);
3747
		deleteProject("P");
3748
	}
3749
}
3750
3751
/*
3718
 * Ensures that unknown classpath attributes in a .classpath file are not lost when read and rewritten.
3752
 * Ensures that unknown classpath attributes in a .classpath file are not lost when read and rewritten.
3719
 * (regression test for bug 101425 Classpath persistence should be resilient with unknown attributes)
3753
 * (regression test for bug 101425 Classpath persistence should be resilient with unknown attributes)
3720
 */
3754
 */

Return to bug 177922