### 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.408 diff -u -r1.408 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 1 Sep 2008 08:53:56 -0000 1.408 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 2 Sep 2008 14:49:48 -0000 @@ -1069,6 +1069,8 @@ if (target instanceof File) { long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target); externalTimeStamps.put(path, new Long(timestamp)); + } else { + externalTimeStamps.put(path, DeltaProcessingState.MISSING_JAR); } } } 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.326 diff -u -r1.326 DeltaProcessor.java --- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 27 Aug 2008 08:59:19 -0000 1.326 +++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 2 Sep 2008 14:49:47 -0000 @@ -864,7 +864,8 @@ Object targetLibrary = JavaModel.getTarget(entryPath, true); if (targetLibrary == null){ // missing JAR - if (this.state.getExternalLibTimeStamps().remove(entryPath) != null /* file was known*/ + Long oldTimestamp = (Long) this.state.getExternalLibTimeStamps().put(entryPath, DeltaProcessingState.MISSING_JAR); + if (oldTimestamp != null && oldTimestamp != DeltaProcessingState.MISSING_JAR/* file was known*/ && this.state.roots.get(entryPath) != null /* and it was on the classpath*/) { externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED); // the jar was physically removed: remove the index @@ -878,11 +879,11 @@ // check timestamp to figure if JAR has changed in some way Long oldTimestamp =(Long) this.state.getExternalLibTimeStamps().get(entryPath); long newTimeStamp = getTimeStamp(externalFile); - if (oldTimestamp != null){ + if (oldTimestamp != null && oldTimestamp != DeltaProcessingState.MISSING_JAR) { if (newTimeStamp == 0){ // file doesn't exist externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED); - this.state.getExternalLibTimeStamps().remove(entryPath); + this.state.getExternalLibTimeStamps().put(entryPath, DeltaProcessingState.MISSING_JAR); // remove the index this.manager.indexManager.removeIndex(entryPath); 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.50 diff -u -r1.50 DeltaProcessingState.java --- model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 27 Jun 2008 16:03:51 -0000 1.50 +++ model/org/eclipse/jdt/internal/core/DeltaProcessingState.java 2 Sep 2008 14:49:47 -0000 @@ -30,6 +30,8 @@ * Keep the global states used during Java element delta processing. */ public class DeltaProcessingState implements IResourceChangeListener { + + public static final Long MISSING_JAR = new Long(-1); /* * Collection of listeners for Java element deltas @@ -449,7 +451,7 @@ while (size-- > 0) { String key = in.readUTF(); long timestamp = in.readLong(); - timeStamps.put(Path.fromPortableString(key), new Long(timestamp)); + timeStamps.put(Path.fromPortableString(key), timestamp == -1 ? MISSING_JAR : new Long(timestamp)); } } catch (IOException e) { if (timestampsFile.exists()) #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v retrieving revision 1.182 diff -u -r1.182 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 1 Sep 2008 14:46:52 -0000 1.182 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 2 Sep 2008 14:49:50 -0000 @@ -2687,7 +2687,7 @@ * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 ) */ -public void testFixClasspath() throws CoreException { +public void testFixClasspath1() throws CoreException { try { createProject("P1"); IJavaProject project = createJavaProject("P2", new String[0], new String[] {"/P1/lib.jar"}, "bin"); @@ -2703,6 +2703,25 @@ deleteProject("P2"); } } +/* + * Ensures that a marker is removed if adding an external jar, restarting and refreshing + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=216446 ) + */ +public void testFixClasspath2() throws CoreException { + try { + IJavaProject p = createJavaProject("P", new String[0], new String[] {getExternalResourcePath("externalLib.abc")}, ""); + waitForAutoBuild(); // 1 marker + createExternalFile("externalLib.abc", ""); + + simulateExitRestart(); + refreshExternalArchives(p); + + assertMarkers("Unexpected markers", "", p); + } finally { + deleteExternalResource("externalLib.abc"); + deleteProject("P"); + } +} /** * Test IJavaProject.hasClasspathCycle(IClasspathEntry[]). */