### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v retrieving revision 1.127 diff -u -r1.127 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 26 Oct 2010 15:50:28 -0000 1.127 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 18 Jan 2011 10:13:55 -0000 @@ -1002,33 +1002,50 @@ /* * Resolves the ".." in the given path. Returns the given path if it contains no ".." segment. */ - public static IPath resolveDotDot(IPath path) { + public static IPath resolveDotDot(IPath reference, IPath path) { IPath newPath = null; - IPath workspaceLocation = null; - for (int i = 0, length = path.segmentCount(); i < length; i++) { - String segment = path.segment(i); - if (DOT_DOT.equals(segment)) { - if (newPath == null) { - if (i == 0) { - workspaceLocation = workspaceRoot.getLocation(); - newPath = workspaceLocation; + IPath workspaceLocation = workspaceRoot.getLocation(); + if (reference == null || workspaceLocation.isPrefixOf(reference)) { + for (int i = 0, length = path.segmentCount(); i < length; i++) { + String segment = path.segment(i); + if (DOT_DOT.equals(segment)) { + if (newPath == null) { + if (i == 0) { + workspaceLocation = workspaceRoot.getLocation(); + newPath = workspaceLocation; + } else { + newPath = path.removeFirstSegments(i); + } } else { - newPath = path.removeFirstSegments(i); + if (newPath.segmentCount() > 0) { + newPath = newPath.removeLastSegments(1); + } else { + workspaceLocation = workspaceRoot.getLocation(); + newPath = workspaceLocation; + } } - } else { - if (newPath.segmentCount() > 0) { - newPath = newPath.removeLastSegments(1); + } else if (newPath != null) { + if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { + newPath = new Path(segment).makeAbsolute(); } else { - workspaceLocation = workspaceRoot.getLocation(); - newPath = workspaceLocation; + newPath = newPath.append(segment); } } - } else if (newPath != null) { - if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { - newPath = new Path(segment).makeAbsolute(); - } else { + } + } + else { + for (int i = 0, length = path.segmentCount(); i < length; i++) { + String segment = path.segment(i); + if (DOT_DOT.equals(segment)) { + if (newPath == null){ + newPath = reference; + } + if (newPath.segmentCount() > 0) { + newPath = newPath.removeLastSegments(1); + } + } else if (newPath != null) { newPath = newPath.append(segment); - } + } } } if (newPath == null) @@ -1419,8 +1436,8 @@ return buffer.toString(); } - public ClasspathEntry resolvedDotDot() { - IPath resolvedPath = resolveDotDot(this.path); + public ClasspathEntry resolvedDotDot(IPath reference) { + IPath resolvedPath = resolveDotDot(reference, this.path); if (resolvedPath == this.path) return this; return new ClasspathEntry( @@ -1919,7 +1936,7 @@ // library entry check case IClasspathEntry.CPE_LIBRARY : - path = ClasspathEntry.resolveDotDot(path); + path = ClasspathEntry.resolveDotDot(project.getProject().getLocation(), path); // do not validate entries from Class-Path: in manifest // (these entries are considered optional since the user cannot act on them) 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.464 diff -u -r1.464 JavaModelManager.java --- model/org/eclipse/jdt/internal/core/JavaModelManager.java 6 Jan 2011 13:43:57 -0000 1.464 +++ model/org/eclipse/jdt/internal/core/JavaModelManager.java 18 Jan 2011 10:13:55 -0000 @@ -2409,6 +2409,10 @@ } public IClasspathEntry resolveVariableEntry(IClasspathEntry entry, boolean usePreviousSession) { + return resolveVariableEntry(entry, ResourcesPlugin.getWorkspace().getRoot().getLocation(), usePreviousSession); + } + + public IClasspathEntry resolveVariableEntry(IClasspathEntry entry, IPath projectPath, boolean usePreviousSession) { if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) return entry; @@ -2416,7 +2420,7 @@ IPath resolvedPath = getResolvedVariablePath(entry.getPath(), usePreviousSession); if (resolvedPath == null) return null; - resolvedPath = ClasspathEntry.resolveDotDot(resolvedPath); + resolvedPath = ClasspathEntry.resolveDotDot(projectPath, resolvedPath); Object target = JavaModel.getTarget(resolvedPath, false); if (target == null) Index: model/org/eclipse/jdt/internal/core/JavaProject.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java,v retrieving revision 1.441 diff -u -r1.441 JavaProject.java --- model/org/eclipse/jdt/internal/core/JavaProject.java 22 Dec 2010 05:56:55 -0000 1.441 +++ model/org/eclipse/jdt/internal/core/JavaProject.java 18 Jan 2011 10:13:55 -0000 @@ -2588,7 +2588,7 @@ for (int index = 0; index < rawClasspath.length; index++) { IClasspathEntry currentEntry = rawClasspath[index]; if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { - rawLibrariesPath.add(ClasspathEntry.resolveDotDot(currentEntry.getPath())); + rawLibrariesPath.add(ClasspathEntry.resolveDotDot(getProject().getLocation(), currentEntry.getPath())); } } if (referencedEntries != null) { @@ -2619,7 +2619,7 @@ case IClasspathEntry.CPE_VARIABLE : try { - resolvedEntry = manager.resolveVariableEntry(rawEntry, usePreviousSession); + resolvedEntry = manager.resolveVariableEntry(rawEntry, this.getProject().getLocation(), usePreviousSession); } catch (ClasspathEntry.AssertionFailedException e) { // Catch the assertion failure and set status instead // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992 @@ -2676,7 +2676,7 @@ if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { // resolve ".." in library path - cEntry = cEntry.resolvedDotDot(); + cEntry = cEntry.resolvedDotDot(getProject().getLocation()); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965 // Do not resolve if the system attribute is set to false if (resolveChainedLibraries @@ -2697,7 +2697,7 @@ case IClasspathEntry.CPE_LIBRARY: // resolve ".." in library path - resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(); + resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(getProject().getLocation()); if (resolveChainedLibraries && result.rawReverseMap.get(resolvedEntry.getPath()) == null) { // resolve Class-Path: in manifest