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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-5 / +10 lines)
Lines 143-148 Link Here
143
	private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
143
	private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
144
	private final static ClasspathEntry[] NO_ENTRIES = new ClasspathEntry[0];
144
	private final static ClasspathEntry[] NO_ENTRIES = new ClasspathEntry[0];
145
	private final static IPath[] NO_PATHS = new IPath[0];
145
	private final static IPath[] NO_PATHS = new IPath[0];
146
	private final static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
146
147
147
	private boolean combineAccessRules;
148
	private boolean combineAccessRules;
148
149
Lines 956-969 Link Here
956
	 */
957
	 */
957
	public static IPath resolveDotDot(IPath path) {
958
	public static IPath resolveDotDot(IPath path) {
958
		IPath newPath = null;
959
		IPath newPath = null;
959
		IWorkspaceRoot root = null;
960
		IPath workspaceLocation = null;
960
		IPath workspaceLocation = null;
961
		for (int i = 0, length = path.segmentCount(); i < length; i++) {
961
		for (int i = 0, length = path.segmentCount(); i < length; i++) {
962
			String segment = path.segment(i);
962
			String segment = path.segment(i);
963
			if (DOT_DOT.equals(segment)) {
963
			if (DOT_DOT.equals(segment)) {
964
				if (newPath == null) {
964
				if (newPath == null) {
965
					if (i == 0) {
965
					if (i == 0) {
966
						workspaceLocation = (root = ResourcesPlugin.getWorkspace().getRoot()).getLocation();
966
						workspaceLocation = workspaceRoot.getLocation();
967
						newPath = workspaceLocation;
967
						newPath = workspaceLocation;
968
					} else {
968
					} else {
969
						newPath = path.removeFirstSegments(i);
969
						newPath = path.removeFirstSegments(i);
Lines 972-983 Link Here
972
					if (newPath.segmentCount() > 0) {
972
					if (newPath.segmentCount() > 0) {
973
						newPath = newPath.removeLastSegments(1);
973
						newPath = newPath.removeLastSegments(1);
974
					} else {
974
					} else {
975
						workspaceLocation = (root = ResourcesPlugin.getWorkspace().getRoot()).getLocation();
975
						workspaceLocation = workspaceRoot.getLocation();
976
						newPath = workspaceLocation;
976
						newPath = workspaceLocation;
977
					}
977
					}
978
				}
978
				}
979
			} else if (newPath != null) {
979
			} else if (newPath != null) {
980
				if (newPath.equals(workspaceLocation) && root.getProject(segment).isAccessible()) {
980
				if (newPath.equals(workspaceLocation) && workspaceRoot.getProject(segment).isAccessible()) {
981
					newPath = new Path(segment).makeAbsolute();
981
					newPath = new Path(segment).makeAbsolute();
982
				} else {
982
				} else {
983
					newPath = newPath.append(segment);
983
					newPath = newPath.append(segment);
Lines 1766-1772 Link Here
1766
	
1766
	
1767
	private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){
1767
	private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){
1768
1768
1769
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1770
		IPath path = entry.getPath();
1769
		IPath path = entry.getPath();
1771
1770
1772
		// Build some common strings for status message
1771
		// Build some common strings for status message
Lines 1960-1965 Link Here
1960
	private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, String container, IPath sourceAttachment, String entryPathMsg) {
1959
	private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, String container, IPath sourceAttachment, String entryPathMsg) {
1961
		if (path.isAbsolute() && !path.isEmpty()) {
1960
		if (path.isAbsolute() && !path.isEmpty()) {
1962
			Object target = JavaModel.getTarget(path, true);
1961
			Object target = JavaModel.getTarget(path, true);
1962
			if (target == null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=248661
1963
				IPath workspaceLocation = workspaceRoot.getLocation(); 
1964
				if (workspaceLocation.isPrefixOf(path)) {
1965
					target = JavaModel.getTarget(path.makeRelativeTo(workspaceLocation).makeAbsolute(), true);
1966
				}
1967
			}
1963
			if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) {
1968
			if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) {
1964
				long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1969
				long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1965
				long libraryJDK = Util.getJdkLevel(target);
1970
				long libraryJDK = Util.getJdkLevel(target);
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+33 lines)
Lines 5938-5942 Link Here
5938
		JavaCore.removeClasspathVariable("MyVar", null);
5938
		JavaCore.removeClasspathVariable("MyVar", null);
5939
	}		
5939
	}		
5940
}
5940
}
5941
/**
5942
 * @bug 248661:Axis2: Missing required libraries in Axis 2 WS Client Projects
5943
 * @test that a variable classpath entry that is mappped to a folder/jar with external path (but still
5944
 * inside the project folder) can be validated using both system absolute path and relative path. 
5945
 * 
5946
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=248661"
5947
 */
5948
public void testBug248661() throws Exception {
5949
	IFolder folder = null;
5950
	try {
5951
		IJavaProject proj =  this.createJavaProject("P", new String[] {}, "bin");
5952
		IPath folderPath = proj.getResource().getFullPath().append("classes");
5953
		folder = createFolder(folderPath);
5954
		assertNotNull(folder);
5955
		IClasspathEntry[] classpath = new IClasspathEntry[1];
5956
		classpath[0] = JavaCore.newVariableEntry(folderPath, null, null);
5957
		setClasspath(proj, classpath);
5958
		
5959
		IClasspathEntry cpe = JavaCore.newLibraryEntry(folder.getFullPath(), null, null);
5960
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(proj, cpe, true);
5961
		assertEquals(IStatus.OK, status.getCode());
5962
		
5963
		cpe = JavaCore.newLibraryEntry(folder.getLocation(), null, null);
5964
		status = JavaConventions.validateClasspathEntry(proj, cpe, true);
5965
		assertEquals(IStatus.OK, status.getCode());
5966
	}
5967
	finally{
5968
		if (folder != null) {
5969
			org.eclipse.jdt.core.tests.util.Util.delete(folder);
5970
		}
5971
		this.deleteProject("P");
5972
	}
5973
}
5941
5974
5942
}
5975
}

Return to bug 248661