View | Details | Raw Unified | Return to bug 274737 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-23 / +40 lines)
Lines 1002-1034 Link Here
1002
	/*
1002
	/*
1003
	 * Resolves the ".." in the given path. Returns the given path if it contains no ".." segment.
1003
	 * Resolves the ".." in the given path. Returns the given path if it contains no ".." segment.
1004
	 */
1004
	 */
1005
	public static IPath resolveDotDot(IPath path) {
1005
	public static IPath resolveDotDot(IPath reference, IPath path) {
1006
		IPath newPath = null;
1006
		IPath newPath = null;
1007
		IPath workspaceLocation = null;
1007
		IPath workspaceLocation = workspaceRoot.getLocation();
1008
		for (int i = 0, length = path.segmentCount(); i < length; i++) {
1008
		if (reference == null || workspaceLocation.isPrefixOf(reference)) {
1009
			String segment = path.segment(i);
1009
			for (int i = 0, length = path.segmentCount(); i < length; i++) {
1010
			if (DOT_DOT.equals(segment)) {
1010
				String segment = path.segment(i);
1011
				if (newPath == null) {
1011
				if (DOT_DOT.equals(segment)) {
1012
					if (i == 0) {
1012
					if (newPath == null) {
1013
						workspaceLocation = workspaceRoot.getLocation();
1013
						if (i == 0) {
1014
						newPath = workspaceLocation;
1014
							workspaceLocation = workspaceRoot.getLocation();
1015
							newPath = workspaceLocation;
1016
						} else {
1017
							newPath = path.removeFirstSegments(i);
1018
						}
1015
					} else {
1019
					} else {
1016
						newPath = path.removeFirstSegments(i);
1020
						if (newPath.segmentCount() > 0) {
1021
							newPath = newPath.removeLastSegments(1);
1022
						} else {
1023
							workspaceLocation = workspaceRoot.getLocation();
1024
							newPath = workspaceLocation;
1025
						}
1017
					}
1026
					}
1018
				} else {
1027
				} else if (newPath != null) {
1019
					if (newPath.segmentCount() > 0) {
1028
					if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) {
1020
						newPath = newPath.removeLastSegments(1);
1029
						newPath = new Path(segment).makeAbsolute();
1021
					} else {
1030
					} else {
1022
						workspaceLocation = workspaceRoot.getLocation();
1031
						newPath = newPath.append(segment);
1023
						newPath = workspaceLocation;
1024
					}
1032
					}
1025
				}
1033
				}
1026
			} else if (newPath != null) {
1034
			}
1027
				if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) {
1035
		}
1028
					newPath = new Path(segment).makeAbsolute();
1036
		else {
1029
				} else {
1037
			for (int i = 0, length = path.segmentCount(); i < length; i++) {
1038
				String segment = path.segment(i);
1039
				if (DOT_DOT.equals(segment)) {
1040
					if (newPath == null){
1041
						newPath = reference;
1042
					}
1043
					if (newPath.segmentCount() > 0) {
1044
						newPath = newPath.removeLastSegments(1);
1045
	 				}
1046
				} else if (newPath != null) {
1030
					newPath = newPath.append(segment);
1047
					newPath = newPath.append(segment);
1031
				}
1048
	 			}
1032
			}
1049
			}
1033
		}
1050
		}
1034
		if (newPath == null)
1051
		if (newPath == null)
Lines 1419-1426 Link Here
1419
		return buffer.toString();
1436
		return buffer.toString();
1420
	}
1437
	}
1421
	
1438
	
1422
	public ClasspathEntry resolvedDotDot() {
1439
	public ClasspathEntry resolvedDotDot(IPath reference) {
1423
		IPath resolvedPath = resolveDotDot(this.path);
1440
		IPath resolvedPath = resolveDotDot(reference, this.path);
1424
		if (resolvedPath == this.path)
1441
		if (resolvedPath == this.path)
1425
			return this;
1442
			return this;
1426
		return new ClasspathEntry(
1443
		return new ClasspathEntry(
Lines 1919-1925 Link Here
1919
1936
1920
			// library entry check
1937
			// library entry check
1921
			case IClasspathEntry.CPE_LIBRARY :
1938
			case IClasspathEntry.CPE_LIBRARY :
1922
				path = ClasspathEntry.resolveDotDot(path);
1939
				path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path);
1923
				
1940
				
1924
				// do not validate entries from Class-Path: in manifest
1941
				// do not validate entries from Class-Path: in manifest
1925
				// (these entries are considered optional since the user cannot act on them)
1942
				// (these entries are considered optional since the user cannot act on them)
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-1 / +5 lines)
Lines 2409-2414 Link Here
2409
	}
2409
	}
2410
2410
2411
	public IClasspathEntry resolveVariableEntry(IClasspathEntry entry, boolean usePreviousSession) {
2411
	public IClasspathEntry resolveVariableEntry(IClasspathEntry entry, boolean usePreviousSession) {
2412
		return resolveVariableEntry(entry, ResourcesPlugin.getWorkspace().getRoot().getLocation(), usePreviousSession);
2413
	}
2414
	
2415
	public IClasspathEntry resolveVariableEntry(IClasspathEntry entry, IPath projectPath, boolean usePreviousSession) {
2412
2416
2413
		if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2417
		if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
2414
			return entry;
2418
			return entry;
Lines 2416-2422 Link Here
2416
		IPath resolvedPath = getResolvedVariablePath(entry.getPath(), usePreviousSession);
2420
		IPath resolvedPath = getResolvedVariablePath(entry.getPath(), usePreviousSession);
2417
		if (resolvedPath == null)
2421
		if (resolvedPath == null)
2418
			return null;
2422
			return null;
2419
		resolvedPath = ClasspathEntry.resolveDotDot(resolvedPath);
2423
		resolvedPath = ClasspathEntry.resolveDotDot(projectPath, resolvedPath);
2420
2424
2421
		Object target = JavaModel.getTarget(resolvedPath, false);
2425
		Object target = JavaModel.getTarget(resolvedPath, false);
2422
		if (target == null)
2426
		if (target == null)
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-4 / +4 lines)
Lines 2588-2594 Link Here
2588
			for (int index = 0; index < rawClasspath.length; index++) {
2588
			for (int index = 0; index < rawClasspath.length; index++) {
2589
				IClasspathEntry currentEntry = rawClasspath[index]; 
2589
				IClasspathEntry currentEntry = rawClasspath[index]; 
2590
				if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2590
				if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2591
					rawLibrariesPath.add(ClasspathEntry.resolveDotDot(currentEntry.getPath()));
2591
					rawLibrariesPath.add(ClasspathEntry.resolveDotDot(getProject().getLocation(), currentEntry.getPath()));
2592
				}
2592
				}
2593
			}
2593
			}
2594
			if (referencedEntries != null) {
2594
			if (referencedEntries != null) {
Lines 2619-2625 Link Here
2619
2619
2620
				case IClasspathEntry.CPE_VARIABLE :
2620
				case IClasspathEntry.CPE_VARIABLE :
2621
					try {
2621
					try {
2622
						resolvedEntry = manager.resolveVariableEntry(rawEntry, usePreviousSession);
2622
						resolvedEntry = manager.resolveVariableEntry(rawEntry, this.getProject().getLocation(), usePreviousSession);
2623
					} catch (ClasspathEntry.AssertionFailedException e) {
2623
					} catch (ClasspathEntry.AssertionFailedException e) {
2624
						// Catch the assertion failure and set status instead
2624
						// Catch the assertion failure and set status instead
2625
						// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
2625
						// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992
Lines 2676-2682 Link Here
2676
						
2676
						
2677
						if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2677
						if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2678
							// resolve ".." in library path
2678
							// resolve ".." in library path
2679
							cEntry = cEntry.resolvedDotDot();
2679
							cEntry = cEntry.resolvedDotDot(getProject().getLocation());
2680
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965
2680
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965
2681
							// Do not resolve if the system attribute is set to false	
2681
							// Do not resolve if the system attribute is set to false	
2682
							if (resolveChainedLibraries
2682
							if (resolveChainedLibraries
Lines 2697-2703 Link Here
2697
2697
2698
				case IClasspathEntry.CPE_LIBRARY:
2698
				case IClasspathEntry.CPE_LIBRARY:
2699
					// resolve ".." in library path
2699
					// resolve ".." in library path
2700
					resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot();
2700
					resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(getProject().getLocation());
2701
					
2701
					
2702
					if (resolveChainedLibraries && result.rawReverseMap.get(resolvedEntry.getPath()) == null) {
2702
					if (resolveChainedLibraries && result.rawReverseMap.get(resolvedEntry.getPath()) == null) {
2703
						// resolve Class-Path: in manifest
2703
						// resolve Class-Path: in manifest

Return to bug 274737