### Eclipse Workspace Patch 1.0 #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.23 diff -u -r1.23 FullSourceWorkspaceModelTests.java --- src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 2 Apr 2007 07:28:54 -0000 1.23 +++ src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java 18 Apr 2007 11:55:11 -0000 @@ -854,6 +854,48 @@ } } +/* + * Performance test for the first use of findType(...) + * (see bug 161175 JarPackageFragmentRoot slow to initialize) + */ +public void testFindType() throws CoreException { + // get 20 projects + IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); + IJavaProject[] allProjects = model.getJavaProjects(); + int max = 20; + IJavaProject[] projects = new IJavaProject[max]; + int index = 0; + for (int i = 0, length = allProjects.length; i < length; i++) { + if (allProjects[i].getElementName().startsWith("org.eclipse")) { + projects[index++] = allProjects[i]; + if (index == max) + break; + } + } + + // warm up + for (int i = 0; i < 5; i++) { + model.close(); + for (int j = 0; j < max; j++) { + projects[j].findType("java.lang.Object"); + } + } + + // measure performance + for (int i = 0; i < 10; i++) { + model.close(); + runGc(); + startMeasuring(); + for (int j = 0; j < max; j++) { + projects[j].findType("java.lang.Object"); + } + stopMeasuring(); + } + + commitMeasurements(); + assertPerformance(); +} + public void testStartJDTPlugin() throws JavaModelException { // store current settings long oldSnapInterval = ENV.getWorkspace().getDescription().getSnapshotInterval(); #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java,v retrieving revision 1.44 diff -u -r1.44 JavaProjectElementInfo.java --- model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java 13 Apr 2007 16:02:15 -0000 1.44 +++ model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java 18 Apr 2007 11:55:12 -0000 @@ -206,13 +206,23 @@ roots = new IPackageFragmentRoot[0]; reverseMap.clear(); } + + DeltaProcessingState deltaState = JavaModelManager.getJavaModelManager().deltaState; + HashMap otherRoots = deltaState.oldOtherRoots; + if (otherRoots == null) { + deltaState.initializeRoots(); + otherRoots = deltaState.otherRoots; + } + HashtableOfArrayToObject fragmentsCache = new HashtableOfArrayToObject(); HashtableOfArrayToObject isPackageCache = new HashtableOfArrayToObject(); for (int i = 0, length = roots.length; i < length; i++) { IPackageFragmentRoot root = roots[i]; IJavaElement[] frags = null; try { - if (root.isArchive() && !root.isOpen()) { + if (root.isArchive() + && !root.isOpen() + && otherRoots.get(((JarPackageFragmentRoot) root).jarPath) == null/*only if jar belongs to 1 project (https://bugs.eclipse.org/bugs/show_bug.cgi?id=161175)*/) { JarPackageFragmentRootInfo info = new JarPackageFragmentRootInfo(); ((JarPackageFragmentRoot) root).computeChildren(info, new HashMap()); frags = info.children;