Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 188870 Details for
Bug 274737
Relative Classpath entries should not be resolved relative to the workspace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated patch
bug_274737.txt (text/plain), 9.91 KB, created by
Jay Arthanareeswaran
on 2011-02-14 01:35:54 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Jay Arthanareeswaran
Created:
2011-02-14 01:35:54 EST
Size:
9.91 KB
patch
obsolete
>### 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 14 Feb 2011 06:27:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -1002,33 +1002,48 @@ > /* > * 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) { >+ newPath = workspaceLocation; >+ } else { >+ newPath = path.removeFirstSegments(i); >+ } > } else { >- newPath = path.removeFirstSegments(i); >+ if (newPath.segmentCount() > 0) { >+ newPath = newPath.removeLastSegments(1); >+ } else { >+ 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 +1434,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 +1934,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 14 Feb 2011 06:27:43 -0000 >@@ -2416,7 +2416,8 @@ > IPath resolvedPath = getResolvedVariablePath(entry.getPath(), usePreviousSession); > if (resolvedPath == null) > return null; >- resolvedPath = ClasspathEntry.resolveDotDot(resolvedPath); >+ // By passing a null reference path, we keep it relative to workspace root. >+ resolvedPath = ClasspathEntry.resolveDotDot(null, 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 14 Feb 2011 06:27:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -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) { >@@ -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 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/ClasspathTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClasspathTests.java,v >retrieving revision 1.222 >diff -u -r1.222 ClasspathTests.java >--- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 7 Jan 2011 20:47:00 -0000 1.222 >+++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 14 Feb 2011 06:27:47 -0000 >@@ -14,11 +14,13 @@ > import java.io.File; > import java.io.FileOutputStream; > import java.io.IOException; >+import java.net.URI; > import java.util.Hashtable; > import java.util.Map; > > import junit.framework.Test; > >+import org.eclipse.core.filesystem.URIUtil; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IMarker; >@@ -6861,5 +6863,53 @@ > deleteProject("P"); > } > } >+/** >+ * @bug 274737: Relative Classpath entries should not be resolved relative to the workspace >+ * >+ * Test that for an external project, relative paths are resolve relative to the project location. >+ * >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=274737" >+ * @throws Exception >+ */ >+public void testBug274737() throws Exception { >+ try { >+ createExternalFolder("development/third_party"); >+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("ExternalProject"); >+ URI uri= URIUtil.toURI(new Path(getExternalResourcePath("development")).append("ExternalProject")); >+ IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName()); >+ desc.setLocationURI(uri); >+ project.create(desc, null); >+ if (!project.isOpen()) { >+ project.open(null); >+ } >+ >+ addJavaNature("ExternalProject"); >+ IJavaProject javaProject = JavaCore.create(project); >+ IClasspathEntry[] classpath = new IClasspathEntry[2]; >+ Util.createJar( >+ new String[0], >+ new String[] { >+ "META-INF/MANIFEST.MF", >+ "Manifest-Version: 1.0\n" + >+ "Class-Path: \n", >+ }, >+ getExternalResourcePath("development/third_party/lib.jar"), >+ JavaCore.VERSION_1_4); >+ createExternalFolder("development/ExternalProject/src"); >+ createExternalFolder("development/ExternalProject/bin"); >+ classpath[0] = JavaCore.newSourceEntry(new Path("/ExternalProject/src"), null, null); >+ classpath[1] = JavaCore.newLibraryEntry(new Path("../third_party/lib.jar"), null, null); >+ javaProject.setRawClasspath(classpath, new Path("/ExternalProject/bin"), null); >+ >+ refresh(javaProject); >+ waitForAutoBuild(); >+ assertMarkers("Unexpected markers", "", javaProject); >+ >+ } finally { >+ deleteProject("ExternalProject"); >+ deleteExternalResource("development"); >+ >+ } >+} > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 274737
:
134162
|
134163
|
185989
|
186986
|
187396
| 188870