### 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.415 diff -u -r1.415 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 10 Oct 2008 09:48:06 -0000 1.415 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 13 Oct 2008 11:38:25 -0000 @@ -1057,10 +1057,12 @@ return this.resolvedClasspath; } - public void forgetExternalTimestamps() { + public void forgetExternalTimestampsAndIndexes() { IClasspathEntry[] classpath = this.resolvedClasspath; if (classpath == null) return; - Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaState.getExternalLibTimeStamps(); + JavaModelManager manager = JavaModelManager.getJavaModelManager(); + IndexManager indexManager = manager.indexManager; + Map externalTimeStamps = manager.deltaState.getExternalLibTimeStamps(); HashMap rootInfos = JavaModelManager.getDeltaState().otherRoots; for (int i = 0, length = classpath.length; i < length; i++) { IClasspathEntry entry = classpath[i]; @@ -1068,6 +1070,7 @@ IPath path = entry.getPath(); if (rootInfos.get(path) == null) { externalTimeStamps.remove(path); + indexManager.removeIndex(path); // force reindexing on next reference (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083 ) } } } @@ -3421,7 +3424,7 @@ PerProjectInfo info= (PerProjectInfo) this.perProjectInfos.get(project); if (info != null) { this.perProjectInfos.remove(project); - info.forgetExternalTimestamps(); + info.forgetExternalTimestampsAndIndexes(); } } } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.157 diff -u -r1.157 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 11 Sep 2008 13:51:21 -0000 1.157 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 13 Oct 2008 11:38:28 -0000 @@ -13,6 +13,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import junit.framework.Test; @@ -26,6 +27,7 @@ import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.search.*; +import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.core.ClassFile; @@ -10226,4 +10228,52 @@ deleteProject("P"); } } + +/** + * @bug 250083: Search indexes are not correctly updated + * @test Ensure that a library that is no longer referenced, modified, and referenced again is re-indexed + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=250083" + */ +public void testBug250083() throws Exception { + String libPath = getExternalResourcePath("lib250083.jar"); + try { + Util.createJar( + new String[] { + "p250083/Y250083.java", + "package p250083;\n" + + "public class Y250083 {}" + }, + new HashMap(), + libPath); + createJavaProject("P", new String[0], new String[] {libPath}, ""); + waitUntilIndexesReady(); + deleteExternalFile(libPath); + deleteProject("P"); + + Util.createJar( + new String[] { + "p250083/X250083.java", + "package p250083;\n" + + "public class X250083 {}" + }, + new HashMap(), + libPath); + createJavaProject("P", new String[0], new String[] {libPath}, ""); + TypeNameMatchCollector collector = new TypeNameMatchCollector(); + new SearchEngine().searchAllTypeNames( + null, + new char[][] {"X250083".toCharArray()}, + SearchEngine.createWorkspaceScope(), + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertSearchResults( + "X250083 (not open) [in X250083.class [in p250083 [in "+ getExternalPath() + "lib250083.jar]]]", + collector); + } finally { + deleteExternalFile(libPath); + deleteProject("P"); + } +} + } \ No newline at end of file