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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelStatus.java (-9 lines)
Lines 364-378 Link Here
364
					}
364
					}
365
					return Messages.bind(Messages.classpath_disabledMultipleOutputLocations, new String[] {newPath.makeRelative().toString(), projectName});
365
					return Messages.bind(Messages.classpath_disabledMultipleOutputLocations, new String[] {newPath.makeRelative().toString(), projectName});
366
366
367
				case INCOMPATIBLE_JDK_LEVEL:
368
						javaProject = (IJavaProject)this.elements[0];
369
						return Messages.bind(Messages.classpath_incompatibleLibraryJDKLevel, new String[]{
370
							javaProject.getElementName(),
371
							javaProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true),
372
							this.path.makeRelative().toString(),
373
							this.string,
374
						});
375
376
				case CANNOT_RETRIEVE_ATTACHED_JAVADOC :
367
				case CANNOT_RETRIEVE_ATTACHED_JAVADOC :
377
					if (this.elements != null && this.elements.length == 1) {
368
					if (this.elements != null && this.elements.length == 1) {
378
						if (this.string != null) {
369
						if (this.string != null) {
(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-14 / +83 lines)
Lines 1745-1750 Link Here
1745
	 * @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
1745
	 * @return a java model status describing the problem related to this classpath entry if any, a status object with code <code>IStatus.OK</code> if the entry is fine
1746
	 */
1746
	 */
1747
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
1747
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
1748
		return validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer);
1749
	}
1750
	
1751
	private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){
1748
1752
1749
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1753
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1750
		IPath path = entry.getPath();
1754
		IPath path = entry.getPath();
Lines 1796-1802 Link Here
1796
										if (description == null) description = path.makeRelative().toString();
1800
										if (description == null) description = path.makeRelative().toString();
1797
										return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path);
1801
										return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path);
1798
								}
1802
								}
1799
								IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, checkSourceAttachment, true/*referred by container*/);
1803
								IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, container, checkSourceAttachment, true/*referred by container*/);
1800
								if (!containerEntryStatus.isOK()){
1804
								if (!containerEntryStatus.isOK()){
1801
									return containerEntryStatus;
1805
									return containerEntryStatus;
1802
								}
1806
								}
Lines 1825-1831 Link Here
1825
					}
1829
					}
1826
1830
1827
					// get validation status
1831
					// get validation status
1828
					IJavaModelStatus status = validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/);
1832
					IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, false/*not referred by container*/);
1829
					if (!status.isOK()) return status;
1833
					if (!status.isOK()) return status;
1830
1834
1831
					// return deprecation status if any
1835
					// return deprecation status if any
Lines 1847-1853 Link Here
1847
				// (these entries are considered optional since the user cannot act on them)
1851
				// (these entries are considered optional since the user cannot act on them)
1848
				// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252392
1852
				// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=252392
1849
				
1853
				
1850
				IJavaModelStatus status = validateLibraryEntry(path, project, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg);
1854
				String containerInfo = null;
1855
				if (entryContainer != null) {
1856
					if (entryContainer instanceof UserLibraryClasspathContainer) {
1857
						containerInfo = Messages.bind(Messages.classpath_userLibraryInfo, new String[] {entryContainer.getDescription()});
1858
					} else {
1859
						containerInfo = Messages.bind(Messages.classpath_containerInfo, new String[] {entryContainer.getDescription()});
1860
					}
1861
				}
1862
				IJavaModelStatus status = validateLibraryEntry(path, project, containerInfo, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg);
1851
				if (!status.isOK())
1863
				if (!status.isOK())
1852
					return status;
1864
					return status;
1853
				break;
1865
				break;
Lines 1868-1874 Link Here
1868
							long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1880
							long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1869
							long prereqProjectTargetJDK = CompilerOptions.versionToJdkLevel(prereqProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1881
							long prereqProjectTargetJDK = CompilerOptions.versionToJdkLevel(prereqProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1870
							if (prereqProjectTargetJDK > projectTargetJDK) {
1882
							if (prereqProjectTargetJDK > projectTargetJDK) {
1871
								return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, project, path, CompilerOptions.versionFromJdkLevel(prereqProjectTargetJDK));
1883
								return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL,
1884
										project, path, 
1885
										Messages.bind(Messages.classpath_incompatibleLibraryJDKLevel,
1886
												new String[] {
1887
													project.getElementName(),
1888
													CompilerOptions.versionFromJdkLevel(projectTargetJDK), 
1889
													path.makeRelative().toString(),
1890
													CompilerOptions.versionFromJdkLevel(prereqProjectTargetJDK)}));
1872
							}
1891
							}
1873
						}
1892
						}
1874
					} catch (CoreException e){
1893
					} catch (CoreException e){
Lines 1916-1929 Link Here
1916
		return JavaModelStatus.VERIFIED_OK;
1935
		return JavaModelStatus.VERIFIED_OK;
1917
	}
1936
	}
1918
1937
1919
	private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, IPath sourceAttachment, String entryPathMsg) {
1938
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=232816, Now we have the facility to include a container
1939
	// name in diagnostics. If the parameter ``container'' is not null, it is used to point to the library
1940
	// more fully.
1941
	private static IJavaModelStatus validateLibraryEntry(IPath path, IJavaProject project, String container, IPath sourceAttachment, String entryPathMsg) {
1920
		if (path.isAbsolute() && !path.isEmpty()) {
1942
		if (path.isAbsolute() && !path.isEmpty()) {
1921
			Object target = JavaModel.getTarget(path, true);
1943
			Object target = JavaModel.getTarget(path, true);
1922
			if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) {
1944
			if (target != null && !JavaCore.IGNORE.equals(project.getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true))) {
1923
				long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1945
				long projectTargetJDK = CompilerOptions.versionToJdkLevel(project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
1924
				long libraryJDK = Util.getJdkLevel(target);
1946
				long libraryJDK = Util.getJdkLevel(target);
1925
				if (libraryJDK != 0 && libraryJDK > projectTargetJDK) {
1947
				if (libraryJDK != 0 && libraryJDK > projectTargetJDK) {
1926
					return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL, project, path, CompilerOptions.versionFromJdkLevel(libraryJDK));
1948
					if (container != null) {
1949
						return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL,
1950
								project, path,
1951
								Messages.bind(Messages.classpath_incompatibleLibraryJDKLevelInContainer,
1952
										new String [] {
1953
											project.getElementName(),
1954
											CompilerOptions.versionFromJdkLevel(projectTargetJDK),
1955
											path.makeRelative().toString(),
1956
											container,
1957
											CompilerOptions.versionFromJdkLevel(libraryJDK)}));
1958
					} else {
1959
						return new JavaModelStatus(IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL,
1960
								project, path, 
1961
								Messages.bind(Messages.classpath_incompatibleLibraryJDKLevel,
1962
										new String[] {
1963
											project.getElementName(),
1964
											CompilerOptions.versionFromJdkLevel(projectTargetJDK), 
1965
											path.makeRelative().toString(),
1966
											CompilerOptions.versionFromJdkLevel(libraryJDK)}));
1967
					}
1927
				}
1968
				}
1928
			}
1969
			}
1929
			if (target instanceof IResource){
1970
			if (target instanceof IResource){
Lines 1933-1971 Link Here
1933
						if (sourceAttachment != null
1974
						if (sourceAttachment != null
1934
							&& !sourceAttachment.isEmpty()
1975
							&& !sourceAttachment.isEmpty()
1935
							&& JavaModel.getTarget(sourceAttachment, true) == null){
1976
							&& JavaModel.getTarget(sourceAttachment, true) == null){
1936
							return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
1977
							if (container != null) {
1978
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toString(), container}));
1979
							} else {
1980
								return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
1981
							}
1937
						}
1982
						}
1938
						break;
1983
						break;
1939
					case IResource.FOLDER :	// internal binary folder
1984
					case IResource.FOLDER :	// internal binary folder
1940
						if (sourceAttachment != null
1985
						if (sourceAttachment != null
1941
							&& !sourceAttachment.isEmpty()
1986
							&& !sourceAttachment.isEmpty()
1942
							&& JavaModel.getTarget(sourceAttachment, true) == null){
1987
							&& JavaModel.getTarget(sourceAttachment, true) == null){
1943
							return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
1988
							if (container != null) {
1989
								return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toString(), container}));
1990
							} else {
1991
								return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toString(), project.getElementName()}));
1992
							}
1944
						}
1993
						}
1945
				}
1994
				}
1946
			} else if (target instanceof File){
1995
			} else if (target instanceof File){
1947
				File file = JavaModel.getFile(target);
1996
				File file = JavaModel.getFile(target);
1948
			    if (file == null) {
1997
			    if (file == null) {
1949
					return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
1998
			    	if (container != null) {
1999
			    		return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container}));
2000
			    	} else {
2001
			    		return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
2002
			    	}
1950
			    } else if (sourceAttachment != null
2003
			    } else if (sourceAttachment != null
1951
						&& !sourceAttachment.isEmpty()
2004
						&& !sourceAttachment.isEmpty()
1952
						&& JavaModel.getTarget(sourceAttachment, true) == null){
2005
						&& JavaModel.getTarget(sourceAttachment, true) == null){
1953
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
2006
			    		if (container != null) {
1954
			    }
2007
			    			return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container}));
2008
			    		} else {
2009
			    			return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
2010
			    		}
2011
			    	}
1955
			} else {
2012
			} else {
1956
				boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists();
2013
				boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists();
1957
				if (isExternal) {
2014
				if (isExternal) {
1958
					return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {path.toOSString(), project.getElementName()}));
2015
					if (container != null) {
2016
						return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibraryInContainer, new String[] {path.toOSString(), container}));
2017
					} else {
2018
						return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {path.toOSString(), project.getElementName()}));	
2019
					}
1959
				} else {
2020
				} else {
1960
					if (entryPathMsg == null) 
2021
					if (entryPathMsg == null) 
1961
						entryPathMsg = 	project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString();
2022
						entryPathMsg = 	project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString();
1962
					return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {entryPathMsg, project.getElementName()}));
2023
					if (container!= null) {	
2024
						return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibraryInContainer, new String[] {entryPathMsg, container}));
2025
					} else {
2026
						return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundLibrary, new String[] {entryPathMsg, project.getElementName()}));
2027
					}
1963
				}
2028
				}
1964
			}
2029
			}
1965
		} else {
2030
		} else {
1966
			if (entryPathMsg == null) 
2031
			if (entryPathMsg == null) 
1967
				entryPathMsg = 	project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString();
2032
				entryPathMsg = 	project.getElementName().equals(path.segment(0)) ? path.removeFirstSegments(1).makeRelative().toString() : path.toString();
1968
			return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryPath, new String[] {entryPathMsg, project.getElementName()}));
2033
				if (container != null) {
2034
					return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryPathInContainer, new String[] {entryPathMsg, container}));
2035
				} else {
2036
					return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalLibraryPath, new String[] {entryPathMsg, project.getElementName()}));
2037
				}
1969
		}
2038
		}
1970
		return JavaModelStatus.VERIFIED_OK;
2039
		return JavaModelStatus.VERIFIED_OK;
1971
	}
2040
	}
(-)model/org/eclipse/jdt/internal/core/util/messages.properties (-1 / +8 lines)
Lines 145-152 Link Here
145
classpath_illegalContainerPath = Illegal classpath container path: ''{0}'' in project ''{1}'', must have at least one segment (containerID+hints)
145
classpath_illegalContainerPath = Illegal classpath container path: ''{0}'' in project ''{1}'', must have at least one segment (containerID+hints)
146
classpath_illegalEntryInClasspathFile = Illegal entry in ''.classpath'' of project ''{0}'' file: {1}
146
classpath_illegalEntryInClasspathFile = Illegal entry in ''.classpath'' of project ''{0}'' file: {1}
147
classpath_illegalLibraryPath = Illegal path for required library: ''{0}'' in project ''{1}''
147
classpath_illegalLibraryPath = Illegal path for required library: ''{0}'' in project ''{1}''
148
classpath_illegalLibraryPathInContainer = Illegal path for required library: ''{0}'' in the {1}
148
classpath_illegalLibraryArchive = Illegal type of archive for required library: ''{0}'' in project ''{1}''
149
classpath_illegalLibraryArchive = Illegal type of archive for required library: ''{0}'' in project ''{1}''
149
classpath_illegalExternalFolder = Required library cannot denote external folder: ''{0}'' for project ''{1}''
150
classpath_illegalExternalFolder = Required library cannot denote external folder: ''{0}'' for project ''{1}''
151
classpath_illegalExternalFolderInContainer = Required library cannot denote external folder: ''{0}'' in the {1}
150
classpath_illegalProjectPath = Illegal path for required project: ''{0}'' in project ''{1}''
152
classpath_illegalProjectPath = Illegal path for required project: ''{0}'' in project ''{1}''
151
classpath_illegalSourceFolderPath = Illegal path for required source folder: ''{0}'' in project ''{1}''
153
classpath_illegalSourceFolderPath = Illegal path for required source folder: ''{0}'' in project ''{1}''
152
classpath_illegalVariablePath = Illegal classpath variable path: ''{0}'' in project ''{1}'', must have at least one segment
154
classpath_illegalVariablePath = Illegal classpath variable path: ''{0}'' in project ''{1}'', must have at least one segment
Lines 155-164 Link Here
155
classpath_mustEndWithSlash = End exclusion filter ''{0}'' with / to fully exclude ''{1}''
157
classpath_mustEndWithSlash = End exclusion filter ''{0}'' with / to fully exclude ''{1}''
156
classpath_unboundContainerPath = Unbound classpath container: ''{0}'' in project ''{1}''
158
classpath_unboundContainerPath = Unbound classpath container: ''{0}'' in project ''{1}''
157
classpath_unboundLibrary = Project ''{1}'' is missing required library: ''{0}''
159
classpath_unboundLibrary = Project ''{1}'' is missing required library: ''{0}''
160
classpath_userLibraryInfo = user library ''{0}''
161
classpath_containerInfo = container ''{0}''
162
classpath_unboundLibraryInContainer = The {1} references non existing library ''{0}''
158
classpath_unboundProject = Project ''{1}'' is missing required Java project: ''{0}''
163
classpath_unboundProject = Project ''{1}'' is missing required Java project: ''{0}''
159
classpath_settingOutputLocationProgress = Setting output location for: ''{0}''
164
classpath_settingOutputLocationProgress = Setting output location for: ''{0}''
160
classpath_settingProgress = Setting classpath for: {0}
165
classpath_settingProgress = Setting classpath for: {0}
161
classpath_unboundSourceAttachment = Invalid source attachment: ''{0}'' for required library ''{1}'' in project ''{1}''
166
classpath_unboundSourceAttachment = Invalid source attachment: ''{0}'' for required library ''{1}'' in project ''{2}''
167
classpath_unboundSourceAttachmentInContainedLibrary = Invalid source attachment: ''{0}'' for required library ''{1}'' in the {2}
162
classpath_unboundSourceFolder = Project ''{1}'' is missing required source folder: ''{0}''
168
classpath_unboundSourceFolder = Project ''{1}'' is missing required source folder: ''{0}''
163
classpath_unboundVariablePath = Unbound classpath variable: ''{0}'' in project ''{1}''
169
classpath_unboundVariablePath = Unbound classpath variable: ''{0}'' in project ''{1}''
164
classpath_unknownKind = Unknown kind: ''{0}''
170
classpath_unknownKind = Unknown kind: ''{0}''
Lines 166-171 Link Here
166
classpath_disabledInclusionExclusionPatterns = Inclusion or exclusion patterns are disabled in project ''{1}'', cannot selectively include or exclude from entry: ''{0}''
172
classpath_disabledInclusionExclusionPatterns = Inclusion or exclusion patterns are disabled in project ''{1}'', cannot selectively include or exclude from entry: ''{0}''
167
classpath_disabledMultipleOutputLocations = Multiple output locations are disabled in project ''{1}'', cannot associate entry: ''{0}'' with a specific output
173
classpath_disabledMultipleOutputLocations = Multiple output locations are disabled in project ''{1}'', cannot associate entry: ''{0}'' with a specific output
168
classpath_incompatibleLibraryJDKLevel = Incompatible .class files version in required binaries. Project ''{0}'' is targeting a {1} runtime, but is compiled against ''{2}'' which requires a {3} runtime
174
classpath_incompatibleLibraryJDKLevel = Incompatible .class files version in required binaries. Project ''{0}'' is targeting a {1} runtime, but is compiled against ''{2}'' which requires a {3} runtime
175
classpath_incompatibleLibraryJDKLevelInContainer = Incompatible .class files version in required binaries. Project ''{0}'' is targeting a {1} runtime, but is compiled against ''{2}'' (from the {3}) which requires a {4} runtime
169
classpath_duplicateEntryExtraAttribute = Duplicate extra attribute: ''{0}'' in classpath entry ''{1}'' for project ''{2}''
176
classpath_duplicateEntryExtraAttribute = Duplicate extra attribute: ''{0}'' in classpath entry ''{1}'' for project ''{2}''
170
classpath_deprecated_variable = Classpath variable ''{0}'' in project ''{1}'' is deprecated: {2}
177
classpath_deprecated_variable = Classpath variable ''{0}'' in project ''{1}'' is deprecated: {2}
171
178
(-)model/org/eclipse/jdt/internal/core/util/Messages.java (+7 lines)
Lines 149-156 Link Here
149
	public static String classpath_illegalContainerPath;
149
	public static String classpath_illegalContainerPath;
150
	public static String classpath_illegalEntryInClasspathFile;
150
	public static String classpath_illegalEntryInClasspathFile;
151
	public static String classpath_illegalLibraryPath;
151
	public static String classpath_illegalLibraryPath;
152
	public static String classpath_illegalLibraryPathInContainer;
152
	public static String classpath_illegalLibraryArchive;
153
	public static String classpath_illegalLibraryArchive;
153
	public static String classpath_illegalExternalFolder;
154
	public static String classpath_illegalExternalFolder;
155
	public static String classpath_illegalExternalFolderInContainer;
154
	public static String classpath_illegalProjectPath;
156
	public static String classpath_illegalProjectPath;
155
	public static String classpath_illegalSourceFolderPath;
157
	public static String classpath_illegalSourceFolderPath;
156
	public static String classpath_illegalVariablePath;
158
	public static String classpath_illegalVariablePath;
Lines 159-168 Link Here
159
	public static String classpath_mustEndWithSlash;
161
	public static String classpath_mustEndWithSlash;
160
	public static String classpath_unboundContainerPath;
162
	public static String classpath_unboundContainerPath;
161
	public static String classpath_unboundLibrary;
163
	public static String classpath_unboundLibrary;
164
	public static String classpath_userLibraryInfo;
165
	public static String classpath_containerInfo;
166
	public static String classpath_unboundLibraryInContainer;
162
	public static String classpath_unboundProject;
167
	public static String classpath_unboundProject;
163
	public static String classpath_settingOutputLocationProgress;
168
	public static String classpath_settingOutputLocationProgress;
164
	public static String classpath_settingProgress;
169
	public static String classpath_settingProgress;
165
	public static String classpath_unboundSourceAttachment;
170
	public static String classpath_unboundSourceAttachment;
171
	public static String classpath_unboundSourceAttachmentInContainedLibrary;
166
	public static String classpath_unboundSourceFolder;
172
	public static String classpath_unboundSourceFolder;
167
	public static String classpath_unboundVariablePath;
173
	public static String classpath_unboundVariablePath;
168
	public static String classpath_unknownKind;
174
	public static String classpath_unknownKind;
Lines 170-175 Link Here
170
	public static String classpath_disabledInclusionExclusionPatterns;
176
	public static String classpath_disabledInclusionExclusionPatterns;
171
	public static String classpath_disabledMultipleOutputLocations;
177
	public static String classpath_disabledMultipleOutputLocations;
172
	public static String classpath_incompatibleLibraryJDKLevel;
178
	public static String classpath_incompatibleLibraryJDKLevel;
179
	public static String classpath_incompatibleLibraryJDKLevelInContainer;
173
	public static String classpath_duplicateEntryExtraAttribute;
180
	public static String classpath_duplicateEntryExtraAttribute;
174
	public static String classpath_deprecated_variable;
181
	public static String classpath_deprecated_variable;
175
	public static String file_notFound;
182
	public static String file_notFound;
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (-1 / +237 lines)
Lines 40-45 Link Here
40
import org.eclipse.core.runtime.Path;
40
import org.eclipse.core.runtime.Path;
41
import org.eclipse.core.runtime.Platform;
41
import org.eclipse.core.runtime.Platform;
42
import org.eclipse.core.runtime.content.IContentDescription;
42
import org.eclipse.core.runtime.content.IContentDescription;
43
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
44
import org.eclipse.core.runtime.preferences.InstanceScope;
45
import org.eclipse.jdt.core.ClasspathContainerInitializer;
43
import org.eclipse.jdt.core.IAccessRule;
46
import org.eclipse.jdt.core.IAccessRule;
44
import org.eclipse.jdt.core.IClasspathAttribute;
47
import org.eclipse.jdt.core.IClasspathAttribute;
45
import org.eclipse.jdt.core.IClasspathContainer;
48
import org.eclipse.jdt.core.IClasspathContainer;
Lines 59-64 Link Here
59
import org.eclipse.jdt.internal.core.ClasspathEntry;
62
import org.eclipse.jdt.internal.core.ClasspathEntry;
60
import org.eclipse.jdt.internal.core.JavaModelManager;
63
import org.eclipse.jdt.internal.core.JavaModelManager;
61
import org.eclipse.jdt.internal.core.JavaProject;
64
import org.eclipse.jdt.internal.core.JavaProject;
65
import org.eclipse.jdt.internal.core.UserLibraryClasspathContainer;
62
import org.eclipse.team.core.RepositoryProvider;
66
import org.eclipse.team.core.RepositoryProvider;
63
67
64
public class ClasspathTests extends ModifyingResourceTests {
68
public class ClasspathTests extends ModifyingResourceTests {
Lines 160-165 Link Here
160
	return result;
164
	return result;
161
}
165
}
162
166
167
/*  https://bugs.eclipse.org/bugs/show_bug.cgi?id=232816: Misleading problem text for missing jar in user
168
 *  library. We now mention the container name in this and related diagnostics so the context and connection is clearer.
169
 *  The bunch of tests with names of the form test232816*() test several paths in the function 
170
 *  org.eclipse.jdt.internal.core.ClasspathEntry.validateLibraryEntry(IPath, IJavaProject, String, IPath, String)
171
 *  with the sole objective of eliciting the various messages under the different conditions (internal/external,
172
 *  file/folder, problem with library/sources etc). The tests probably make not much sense other than to trigger
173
 *  errors.
174
 */
175
 
176
public void test232816() throws Exception {
177
	
178
	IJavaProject p = null;
179
	try {
180
		p = createJavaProject("P");
181
		JavaCore.setClasspathContainer(
182
				new Path("container/default"),
183
					new IJavaProject[]{ p },
184
					new IClasspathContainer[] {
185
						new TestContainer(new Path("container/default"),
186
							new IClasspathEntry[]{
187
								JavaCore.newLibraryEntry(new Path(getExternalResourcePath("libjar.jar")), new Path("/P0/SBlah"), new Path("/P0"))})
188
					},
189
					null);
190
191
				IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default"));
192
				
193
				IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true);
194
				assertStatus(
195
					"should have complained about missing library",
196
					"The container \'container/default\' references non existing library \'" + getExternalResourcePath("libjar.jar") + "'",
197
					status);
198
	} finally {
199
		deleteProject("P");
200
	}
201
}
202
203
204
public void test232816a() throws Exception {
205
	
206
	IJavaProject p = null;
207
	try {
208
		p = createJavaProject("P");
209
		addExternalLibrary(p, getExternalResourcePath("lib1.jar"), new String[0], 
210
			new String[] {
211
				"META-INF/MANIFEST.MF",
212
				"Manifest-Version: 1.0\n" +
213
				"Class-Path: lib2.jar\n",
214
			},
215
			JavaCore.VERSION_1_4);
216
		refreshExternalArchives(p);
217
218
		JavaCore.setClasspathContainer(
219
				new Path("container/default"),
220
					new IJavaProject[]{ p },
221
					new IClasspathContainer[] {
222
						new TestContainer(new Path("container/default"),
223
							new IClasspathEntry[]{
224
								JavaCore.newLibraryEntry(new Path(getExternalResourcePath("lib1.jar")), new Path("/P0/SBlah"), new Path("/P0"))})
225
					},
226
					null);
227
228
				IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default"));
229
				
230
				IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true);
231
				assertStatus(
232
					"should have complained about source attachment",
233
					"Invalid source attachment: '/P0/SBlah' for required library \'" + getExternalResourcePath("lib1.jar") + "' in the container 'container/default'",
234
					status);
235
	} finally {
236
		deleteProject("P");
237
		deleteExternalResource("lib1.jar");
238
	}
239
}
240
241
public void test232816b() throws Exception {
242
	
243
	try {
244
		IJavaProject p = createJavaProject("Project");
245
		// Create new user library "SomeUserLibrary"
246
		ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID);
247
		String libraryName = "SomeUserLibrary";
248
		IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID);
249
		UserLibraryClasspathContainer containerSuggestion = new UserLibraryClasspathContainer(libraryName);
250
		initializer.requestClasspathContainerUpdate(containerPath.append(libraryName), null, containerSuggestion);
251
252
		// Modify user library
253
		IEclipsePreferences preferences = new InstanceScope().getNode(JavaCore.PLUGIN_ID);
254
		String propertyName = JavaModelManager.CP_USERLIBRARY_PREFERENCES_PREFIX+"SomeUserLibrary";
255
		StringBuffer propertyValue = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<userlibrary systemlibrary=\"false\" version=\"1\">\r\n<archive");
256
		//String jarFullPath = getWorkspaceRoot().getLocation().append(jarFile.getFullPath()).toString();
257
		propertyValue.append(" path=\"" + getExternalResourcePath("idontexistthereforeiamnot.jar"));
258
		propertyValue.append("\"/>\r\n</userlibrary>\r\n");
259
		preferences.put(propertyName, propertyValue.toString());
260
		preferences.flush();
261
		
262
		
263
		IClasspathEntry[] entries = p.getRawClasspath();
264
		int length = entries.length;
265
		System.arraycopy(entries, 0, entries = new IClasspathEntry[length+1], 0, length);
266
		entries[length] = JavaCore.newContainerEntry(containerSuggestion.getPath());
267
		p.setRawClasspath(entries, null);
268
269
		assertMarkers("Failed to find marker", "The user library 'SomeUserLibrary' references non existing library \'" + getExternalResourcePath("idontexistthereforeiamnot.jar") + "'", p);
270
	} finally {
271
		deleteProject("Project");
272
	}
273
}
274
275
276
public void test232816c() throws CoreException {
277
278
	IJavaProject p = null;
279
	try {
280
281
		p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0");
282
      
283
		JavaCore.setClasspathContainer(
284
		new Path("container/default"),
285
			new IJavaProject[]{ p },
286
			new IClasspathContainer[] {
287
				new TestContainer(new Path("container/default"),
288
					new IClasspathEntry[]{
289
						JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"))})
290
			},
291
			null);
292
293
		IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default"));
294
		
295
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true);
296
		assertStatus(
297
			"should have complained about missing library",
298
			"The container 'container/default' references non existing library 'JUNK'",
299
			status);
300
301
	} finally {
302
		deleteProject ("P0");
303
	}
304
}
305
306
307
public void test232816d() throws CoreException {
308
309
	IJavaProject p = null;
310
	try {
311
312
		p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0");
313
314
		JavaCore.setClasspathContainer(
315
		new Path("container/default"),
316
			new IJavaProject[]{ p },
317
			new IClasspathContainer[] {
318
				new TestContainer(new Path("container/default"),
319
					new IClasspathEntry[]{
320
						JavaCore.newLibraryEntry(new Path("/P0/src0"), new Path("/P0/SBlah"), new Path("/P0"))})
321
			},
322
			null);
323
324
		IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default"));
325
		
326
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true);
327
		assertStatus(
328
			"should have complained about source attachment",
329
			"Invalid source attachment: '/P0/SBlah' for required library '/P0/src0' in the container 'container/default'",
330
			status);
331
332
	} finally {
333
		deleteProject ("P0");
334
	}
335
}
336
337
public void test232816e() throws CoreException {
338
339
	IJavaProject p = null;
340
	try {
341
342
		p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0");
343
		createFile("/P0/src0/X.class", "");
344
		JavaCore.setClasspathContainer(
345
		new Path("container/default"),
346
			new IJavaProject[]{ p },
347
			new IClasspathContainer[] {
348
				new TestContainer(new Path("container/default"),
349
					new IClasspathEntry[]{
350
						JavaCore.newLibraryEntry(new Path("/P0/src0/X.class"), new Path("/P0/SBlah"), new Path("/P0"))})
351
			},
352
			null);
353
354
		IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default"));
355
		
356
		IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true);
357
		assertStatus(
358
			"should have complained about source attachment",
359
			"Invalid source attachment: '/P0/SBlah' for required library '/P0/src0/X.class' in the container 'container/default'",
360
			status);
361
362
	} finally {
363
		deleteProject ("P0");
364
	}
365
}
366
367
public void test232816f() throws Exception {
368
	
369
	IJavaProject p = null;
370
	try {
371
		p = createJavaProject("P");
372
		
373
		p.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
374
		p.setOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.WARNING);
375
		
376
		JavaCore.setClasspathContainer(
377
				new Path("container/default"),
378
					new IJavaProject[]{ p },
379
					new IClasspathContainer[] {
380
						new TestContainer(new Path("container/default"),
381
							new IClasspathEntry[]{
382
								JavaCore.newLibraryEntry(getExternalJCLPath("1.5"), new Path("/P0/SBlah"), new Path("/P0"))})
383
					},
384
					null);
385
386
				IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default"));
387
				
388
				IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true);
389
				assertStatus(
390
					"should have complained about jdk level mismatch",
391
					"Incompatible .class files version in required binaries. Project 'P' is targeting a 1.4 runtime, but is compiled against \'" + getExternalJCLPath("1.5").makeRelative() + "' (from the container 'container/default') which requires a 1.5 runtime",
392
					status);
393
	} finally {
394
		deleteProject("P");
395
	}
396
}
397
398
163
/*
399
/*
164
 * Ensures that adding a library entry for an existing external library folder doesn't generate a marker
400
 * Ensures that adding a library entry for an existing external library folder doesn't generate a marker
165
 */
401
 */
Lines 2341-2347 Link Here
2341
		setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"))});
2577
		setClasspath(p, new IClasspathEntry[] {JavaCore.newContainerEntry(new Path("org.eclipse.jdt.core.tests.model.TEST_CONTAINER"))});
2342
		assertMarkers(
2578
		assertMarkers(
2343
			"Unexpected markers", 
2579
			"Unexpected markers", 
2344
			"Project \'P\' is missing required library: \'"+ getExternalPath() + "nonExisting.jar\'",
2580
			"The container 'Test container' references non existing library \'" + getExternalPath() + "nonExisting.jar\'",
2345
			p);
2581
			p);
2346
	} finally {
2582
	} finally {
2347
		deleteProject("P");
2583
		deleteProject("P");

Return to bug 232816