### 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.117 diff -u -r1.117 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 21 Apr 2009 04:39:55 -0000 1.117 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 18 Aug 2009 09:01:07 -0000 @@ -143,6 +143,7 @@ private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$ private final static ClasspathEntry[] NO_ENTRIES = new ClasspathEntry[0]; private final static IPath[] NO_PATHS = new IPath[0]; + private final static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); private boolean combineAccessRules; @@ -956,14 +957,13 @@ */ public static IPath resolveDotDot(IPath path) { IPath newPath = null; - IWorkspaceRoot root = 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 = (root = ResourcesPlugin.getWorkspace().getRoot()).getLocation(); + workspaceLocation = workspaceRoot.getLocation(); newPath = workspaceLocation; } else { newPath = path.removeFirstSegments(i); @@ -972,12 +972,12 @@ if (newPath.segmentCount() > 0) { newPath = newPath.removeLastSegments(1); } else { - workspaceLocation = (root = ResourcesPlugin.getWorkspace().getRoot()).getLocation(); + workspaceLocation = workspaceRoot.getLocation(); newPath = workspaceLocation; } } } else if (newPath != null) { - if (newPath.equals(workspaceLocation) && root.getProject(segment).isAccessible()) { + if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) { newPath = new Path(segment).makeAbsolute(); } else { newPath = newPath.append(segment); @@ -1766,7 +1766,6 @@ private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){ - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IPath path = entry.getPath(); // Build some common strings for status message @@ -1960,6 +1959,12 @@ private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, String container, IPath sourceAttachment, String entryPathMsg) { if (path.isAbsolute() && !path.isEmpty()) { Object target = JavaModel.getTarget(path, true); + if (target == null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=248661 + IPath workspaceLocation = workspaceRoot.getLocation(); + if (workspaceLocation.isPrefixOf(path)) { + target = JavaModel.getTarget(path.makeRelativeTo(workspaceLocation).makeAbsolute(), true); + } + } if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) { long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true)); long libraryJDK = Util.getJdkLevel(target); #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.202 diff -u -r1.202 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 8 Jul 2009 07:12:22 -0000 1.202 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 18 Aug 2009 09:01:13 -0000 @@ -5938,5 +5938,38 @@ JavaCore.removeClasspathVariable("MyVar", null); } } +/** + * @bug 248661:Axis2: Missing required libraries in Axis 2 WS Client Projects + * @test that a variable classpath entry that is mappped to a folder/jar with external path (but still + * inside the project folder) can be validated using both system absolute path and relative path. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=248661" + */ +public void testBug248661() throws Exception { + IFolder folder = null; + try { + IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); + IPath folderPath = proj.getResource().getFullPath().append("classes"); + folder = createFolder(folderPath); + assertNotNull(folder); + IClasspathEntry[] classpath = new IClasspathEntry[1]; + classpath[0] = JavaCore.newVariableEntry(folderPath, null, null); + setClasspath(proj, classpath); + + IClasspathEntry cpe = JavaCore.newLibraryEntry(folder.getFullPath(), null, null); + IJavaModelStatus status = JavaConventions.validateClasspathEntry(proj, cpe, true); + assertEquals(IStatus.OK, status.getCode()); + + cpe = JavaCore.newLibraryEntry(folder.getLocation(), null, null); + status = JavaConventions.validateClasspathEntry(proj, cpe, true); + assertEquals(IStatus.OK, status.getCode()); + } + finally{ + if (folder != null) { + org.eclipse.jdt.core.tests.util.Util.delete(folder); + } + this.deleteProject("P"); + } +} }