### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core 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.338 diff -u -r1.338 DeltaProcessor.java --- model/org/eclipse/jdt/internal/core/DeltaProcessor.java 20 May 2010 14:12:01 -0000 1.338 +++ model/org/eclipse/jdt/internal/core/DeltaProcessor.java 8 Dec 2010 07:17:52 -0000 @@ -353,7 +353,7 @@ // java project doesn't exist: ignore } removeFromParentInfo(javaProject); - this.manager.removePerProjectInfo(javaProject); + this.manager.removePerProjectInfo(javaProject, false /* don't remove index files and timestamp info of external jar */); this.manager.containerRemove(javaProject); } this.state.rootsAreStale = true; @@ -376,7 +376,7 @@ checkExternalFolderChange(project, javaProject); } else { // remove classpath cache so that initializeRoots() will not consider the project has a classpath - this.manager.removePerProjectInfo(javaProject); + this.manager.removePerProjectInfo(javaProject, true /* remove external jar files indexes and timestamps */); // remove container cache for this project this.manager.containerRemove(javaProject); // close project @@ -409,7 +409,7 @@ this.manager.forceBatchInitializations(false/*not initAfterLoad*/); // remove classpath cache so that initializeRoots() will not consider the project has a classpath - this.manager.removePerProjectInfo(javaProject); + this.manager.removePerProjectInfo(javaProject, true /* remove external jar files indexes and timestamps*/); // remove container cache for this project this.manager.containerRemove(javaProject); @@ -893,6 +893,7 @@ externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED); this.state.getExternalLibTimeStamps().put(entryPath, new Long(newTimeStamp)); // index the new jar + this.manager.indexManager.removeIndex(entryPath); this.manager.indexManager.indexLibrary(entryPath, project.getProject()); } } Index: model/org/eclipse/jdt/internal/core/DiscardWorkingCopyOperation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DiscardWorkingCopyOperation.java,v retrieving revision 1.15 diff -u -r1.15 DiscardWorkingCopyOperation.java --- model/org/eclipse/jdt/internal/core/DiscardWorkingCopyOperation.java 7 Mar 2009 01:08:08 -0000 1.15 +++ model/org/eclipse/jdt/internal/core/DiscardWorkingCopyOperation.java 8 Dec 2010 07:17:52 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,7 +32,7 @@ if (useCount == 0) { IJavaProject javaProject = workingCopy.getJavaProject(); if (ExternalJavaProject.EXTERNAL_PROJECT_NAME.equals(javaProject.getElementName())) { - manager.removePerProjectInfo((JavaProject) javaProject); + manager.removePerProjectInfo((JavaProject) javaProject, true /* remove external jar files indexes and timestamps*/); manager.containerRemove(javaProject); } if (!workingCopy.isPrimary()) { 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.452 diff -u -r1.452 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 27 May 2010 10:10:34 -0000 1.452 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 8 Dec 2010 07:17:53 -0000 @@ -3655,13 +3655,15 @@ return null; } - public void removePerProjectInfo(JavaProject javaProject) { + public void removePerProjectInfo(JavaProject javaProject, boolean removeExtJarInfo) { synchronized(this.perProjectInfos) { // use the perProjectInfo collection as its own lock IProject project = javaProject.getProject(); PerProjectInfo info= (PerProjectInfo) this.perProjectInfos.get(project); if (info != null) { this.perProjectInfos.remove(project); - info.forgetExternalTimestampsAndIndexes(); + if (removeExtJarInfo) { + info.forgetExternalTimestampsAndIndexes(); + } } } resetNonChainingJarsCache(); Index: model/org/eclipse/jdt/internal/core/ModelUpdater.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModelUpdater.java,v retrieving revision 1.24 diff -u -r1.24 ModelUpdater.java --- model/org/eclipse/jdt/internal/core/ModelUpdater.java 7 Mar 2009 00:58:55 -0000 1.24 +++ model/org/eclipse/jdt/internal/core/ModelUpdater.java 8 Dec 2010 07:17:53 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -130,7 +130,7 @@ case IJavaElement.JAVA_PROJECT : JavaModelManager manager = JavaModelManager.getJavaModelManager(); JavaProject javaProject = (JavaProject) element; - manager.removePerProjectInfo(javaProject); + manager.removePerProjectInfo(javaProject, true /* remove external jar files indexes and timestamps*/); manager.containerRemove(javaProject); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT : #P org.eclipse.jdt.core.tests.builder Index: src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java,v retrieving revision 1.24 diff -u -r1.24 OutputFolderTests.java --- src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java 28 Apr 2009 17:00:26 -0000 1.24 +++ src/org/eclipse/jdt/core/tests/builder/OutputFolderTests.java 8 Dec 2010 07:17:56 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -117,7 +117,7 @@ // simulate exit/restart JavaModelManager manager = JavaModelManager.getJavaModelManager(); JavaProject project = (JavaProject)manager.getJavaModel().getJavaProject("P"); //$NON-NLS-1$ - manager.removePerProjectInfo(project); + manager.removePerProjectInfo(project, true /* remove external jar files indexes and timestamps*/); // change cu and build IPath cuPath = env.addClass(projectPath, "src", "A", //$NON-NLS-1$ //$NON-NLS-2$ #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.198.2.2 diff -u -r1.198.2.2 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 25 Aug 2010 07:41:57 -0000 1.198.2.2 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Dec 2010 07:18:01 -0000 @@ -19,6 +19,7 @@ import junit.framework.Test; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; @@ -43,6 +44,7 @@ import org.eclipse.jdt.internal.core.index.DiskIndex; import org.eclipse.jdt.internal.core.index.Index; import org.eclipse.jdt.internal.core.search.AbstractSearchScope; +import org.eclipse.jdt.internal.core.search.BasicSearchEngine; import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; import org.eclipse.jdt.internal.core.search.indexing.IndexRequest; import org.eclipse.jdt.internal.core.search.matching.AndPattern; @@ -12060,4 +12062,164 @@ deleteProject("P"); } } + +/** + * @bug 323514: Search indexes are not correctly updated + * @test [indexing] The Java Indexer is taking longer to run in eclipse 3.6 when opening projects + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=323514" + */ +public void testBug323514() throws Exception { + String libPath = getExternalResourcePath("lib323514.jar"); + waitUntilIndexesReady(); + try { + // Create project and external jar file + Util.createJar( + new String[] { + "p323514/Y323514.java", + "package p323514;\n" + + "public class Y323514 {}" + }, + new HashMap(), + libPath); + IJavaProject javaProject = createJavaProject("P", new String[0], new String[] {libPath}, ""); + waitUntilIndexesReady(); + + // Close the project + IProject project = javaProject.getProject(); + project.close(null); + assertNotNull("External jar file index should not have been removed!!!", JavaModelManager.getIndexManager().getIndex(new Path(libPath), false, false)); + + // Reopen the project + project.open(null); + project.refreshLocal(IResource.DEPTH_INFINITE, null); + waitUntilIndexesReady(); + // Search + TypeNameMatchCollector collector = new TypeNameMatchCollector(); + new SearchEngine().searchAllTypeNames( + null, + null, + BasicSearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }), + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertSearchResults( + "Y323514 (not open) [in Y323514.class [in p323514 [in "+ getExternalPath() + "lib323514.jar]]]", + collector); + } finally { + deleteExternalFile(libPath); + deleteProject("P"); + org.eclipse.jdt.internal.core.search.processing.JobManager.VERBOSE = false; + } +} +public void testBug323514a() throws Exception { + String libPath = getExternalResourcePath("lib323514.jar"); + waitUntilIndexesReady(); + try { + // Create project and external jar file + Util.createJar( + new String[] { + "p323514/Y323514.java", + "package p323514;\n" + + "public class Y323514 {}" + }, + new HashMap(), + libPath); + IJavaProject javaProject = createJavaProject("P", new String[0], new String[] {libPath}, ""); + waitUntilIndexesReady(); + + // Close project and delete external jar file + IProject project = javaProject.getProject(); + waitUntilIndexesReady(); + project.close(null); + deleteExternalFile(libPath); + Thread.sleep(1000); // necessary for filesystems with timestamps only upto seconds (eg. Mac) + // Open project and recreate external jar file + Util.createJar( + new String[] { + "p323514/X323514.java", + "package p323514;\n" + + "public class X323514 {}" + }, + new HashMap(), + libPath); + project.open(null); + // A refresh external archives seems to be necessary when the external + // archive has been modified while the project was closed... like a refresh + // in the workspace to see external files changes. + project.refreshLocal(IResource.DEPTH_INFINITE, null); + waitUntilIndexesReady(); + + // Search + TypeNameMatchCollector collector = new TypeNameMatchCollector(); + new SearchEngine().searchAllTypeNames( + null, + null, + BasicSearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }), + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertSearchResults( + "X323514 (not open) [in X323514.class [in p323514 [in "+ getExternalPath() + "lib323514.jar]]]", + collector); + } finally { + deleteExternalFile(libPath); + deleteProject("P"); + } +} +public void testBug323514b() throws Exception { + String libPath = getExternalResourcePath("lib323514.jar"); + waitUntilIndexesReady(); + boolean isDebugging = false; // turn to true to verify using the trace that the external jar file is not re-indexed while opening the project + org.eclipse.jdt.internal.core.search.processing.JobManager.VERBOSE = isDebugging; + try { + // Create project and external jar file + Util.createJar( + new String[] { + "p323514/Y323514.java", + "package p323514;\n" + + "public class Y323514 {}" + }, + new HashMap(), + libPath); + IJavaProject javaProject = createJavaProject("P", new String[0], new String[] {libPath}, ""); + waitUntilIndexesReady(); + + // Close project + IProject project = javaProject.getProject(); + project.close(null); + waitUntilIndexesReady(); + Thread.sleep(1000); // necessary for filesystems with timestamps only upto seconds (eg. Mac) + // Open project and modify the external jar file content + Util.createJar( + new String[] { + "p323514/X323514.java", + "package p323514;\n" + + "public class X323514 {}" + }, + new HashMap(), + libPath); + project.open(null); + // A refresh external archives seems to be necessary when the external + // archive has been modified while the project was closed... like a refresh + // in the workspace to see external files changes. + project.refreshLocal(IResource.DEPTH_INFINITE, null); + waitUntilIndexesReady(); + + // Search + TypeNameMatchCollector collector = new TypeNameMatchCollector(); + new SearchEngine().searchAllTypeNames( + null, + null, + BasicSearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }), + collector, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null); + assertSearchResults( + "X323514 (not open) [in X323514.class [in p323514 [in "+ getExternalPath() + "lib323514.jar]]]", + collector); + } finally { + deleteExternalFile(libPath); + deleteProject("P"); + } +} } \ No newline at end of file Index: src/org/eclipse/jdt/core/tests/model/ThreadSafetyTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ThreadSafetyTests.java,v retrieving revision 1.21 diff -u -r1.21 ThreadSafetyTests.java --- src/org/eclipse/jdt/core/tests/model/ThreadSafetyTests.java 27 Jun 2008 16:02:39 -0000 1.21 +++ src/org/eclipse/jdt/core/tests/model/ThreadSafetyTests.java 8 Dec 2010 07:18:01 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,7 +52,7 @@ JavaModelManager manager = JavaModelManager.getJavaModelManager(); manager.previousSessionContainers = new HashMap(5); manager.containers = new HashMap(5); - manager.removePerProjectInfo((JavaProject)project); + manager.removePerProjectInfo((JavaProject)project, true /* remove external jar files indexes and timestamps*/); // use a thread to hold the lock, so as to recreate potential deadlock situation final Semaphore step1 = new Semaphore("<1:permission to populate JavaModel inducing containers inits>", 0); // first acquisition will wait #P org.eclipse.jdt.core.tests.performance Index: src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.performance/src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java,v retrieving revision 1.48 diff -u -r1.48 FullSourceWorkspaceModelTests.java --- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 27 Oct 2009 13:05:53 -0000 1.48 +++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 8 Dec 2010 07:18:03 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1283,6 +1283,94 @@ } } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331632 +public void testReopenSingleProject() throws CoreException { + tagAsSummary("Reopen a single project in a workspace", false); // do NOT put in fingerprint + + // First close all Eclipse projects + long startTime = 0; + if (PRINT) { + System.out.print("Close all Eclipse projects..."); + startTime = System.currentTimeMillis(); + } + int length=ALL_PROJECTS.length; + for (int j=0; j