View | Details | Raw Unified | Return to bug 133141
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (+11 lines)
Lines 47-52 Link Here
47
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
47
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
48
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
48
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
49
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
49
import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToInt;
50
import org.eclipse.jdt.internal.core.JavaProjectElementInfo.ProjectCache;
50
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
51
import org.eclipse.jdt.internal.core.builder.JavaBuilder;
51
import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
52
import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
52
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
53
import org.eclipse.jdt.internal.core.search.AbstractSearchScope;
Lines 55-60 Link Here
55
import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope;
56
import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope;
56
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
57
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
57
import org.eclipse.jdt.internal.core.search.processing.JobManager;
58
import org.eclipse.jdt.internal.core.search.processing.JobManager;
59
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject;
58
import org.eclipse.jdt.internal.core.util.LRUCache;
60
import org.eclipse.jdt.internal.core.util.LRUCache;
59
import org.eclipse.jdt.internal.core.util.Messages;
61
import org.eclipse.jdt.internal.core.util.Messages;
60
import org.eclipse.jdt.internal.core.util.Util;
62
import org.eclipse.jdt.internal.core.util.Util;
Lines 893-898 Link Here
893
			
895
			
894
		IPath resourcePath = resource.getFullPath();
896
		IPath resourcePath = resource.getFullPath();
895
		try {
897
		try {
898
			JavaProjectElementInfo projectInfo = (JavaProjectElementInfo) getJavaModelManager().getInfo(project);
899
			ProjectCache projectCache = projectInfo == null ? null : projectInfo.projectCache;
900
			HashtableOfArrayToObject allPkgFragmentsCache = projectCache == null ? null : projectCache.allPkgFragmentsCache;
896
			IClasspathEntry[] entries = 
901
			IClasspathEntry[] entries = 
897
				org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment())
902
				org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(resourcePath.lastSegment())
898
					? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
903
					? project.getRawClasspath() // JAVA file can only live inside SRC folder (on the raw path)
Lines 922-927 Link Here
922
								pkgPath = pkgPath.removeLastSegments(1);
927
								pkgPath = pkgPath.removeLastSegments(1);
923
							}
928
							}
924
							String[] pkgName = pkgPath.segments();
929
							String[] pkgName = pkgPath.segments();
930
							
931
							// if package name is in the cache, then it has already been validated
932
							// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141)
933
							if (allPkgFragmentsCache != null && allPkgFragmentsCache.containsKey(pkgName))
934
								return root.getPackageFragment(pkgName);
935
							
925
							if (pkgName.length != 0 && JavaConventions.validatePackageName(Util.packageName(pkgPath, sourceLevel, complianceLevel), sourceLevel, complianceLevel).getSeverity() == IStatus.ERROR) {
936
							if (pkgName.length != 0 && JavaConventions.validatePackageName(Util.packageName(pkgPath, sourceLevel, complianceLevel), sourceLevel, complianceLevel).getSeverity() == IStatus.ERROR) {
926
								return null;
937
								return null;
927
							}
938
							}
(-)src/org/eclipse/jdt/core/tests/performance/FullSourceWorkspaceModelTests.java (+32 lines)
Lines 846-851 Link Here
846
	assertPerformance();
846
	assertPerformance();
847
}
847
}
848
848
849
/*
850
 * Tests the performance of JavaCore#create(IResource).
851
 * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133141)
852
 */
853
public void testCreateJavaElement() throws CoreException {
854
	// setup (force the project cache to be created)
855
	IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(BIG_PROJECT_TYPE_PATH);
856
	getNameLookup((JavaProject) JavaCore.create(file.getProject()));
857
	
858
	// warm up
859
	int warmup = WARMUP_COUNT / 10;
860
	int iterations = 5000;
861
	for (int i = 0; i < warmup; i++) {
862
		for (int j = 0; j < iterations; j++) {
863
			JavaCore.create(file);
864
		}
865
	}
866
		
867
	// measure performance
868
	for (int i = 0; i < MEASURES_COUNT; i++) {
869
		runGc();
870
		startMeasuring();
871
		for (int j = 0; j < iterations; j++) {
872
			JavaCore.create(file);
873
		}
874
		stopMeasuring();
875
	}
876
877
	commitMeasurements();
878
	assertPerformance();
879
}
880
849
public void testInitJDTPlugin() throws JavaModelException, CoreException {
881
public void testInitJDTPlugin() throws JavaModelException, CoreException {
850
	tagAsSummary("JDT/Core plugin initialization", true); // put in fingerprint
882
	tagAsSummary("JDT/Core plugin initialization", true); // put in fingerprint
851
883

Return to bug 133141