View | Details | Raw Unified | Return to bug 250946
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-9 / +10 lines)
Lines 1727-1736 Link Here
1727
	 * @param project the given java project
1727
	 * @param project the given java project
1728
	 * @param entry the given classpath entry
1728
	 * @param entry the given classpath entry
1729
	 * @param checkSourceAttachment a flag to determine if source attachment should be checked
1729
	 * @param checkSourceAttachment a flag to determine if source attachment should be checked
1730
	 * @param recurseInContainers flag indicating whether validation should be applied to container entries recursively
1730
	 * @param referredByContainer flag indicating whether the given entry is referred by a classpath container
1731
	 * @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
1731
	 * @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
1732
	 */
1732
	 */
1733
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean recurseInContainers){
1733
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){
1734
1734
1735
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1735
		IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
1736
		IPath path = entry.getPath();
1736
		IPath path = entry.getPath();
Lines 1782-1792 Link Here
1782
										if (description == null) description = path.makeRelative().toString();
1782
										if (description == null) description = path.makeRelative().toString();
1783
										return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path);
1783
										return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, project, path);
1784
								}
1784
								}
1785
								if (recurseInContainers) {
1785
								IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, checkSourceAttachment, true/*referred by container*/);
1786
									IJavaModelStatus containerEntryStatus = validateClasspathEntry(project, containerEntry, checkSourceAttachment, recurseInContainers);
1786
								if (!containerEntryStatus.isOK()){
1787
									if (!containerEntryStatus.isOK()){
1787
									return containerEntryStatus;
1788
										return containerEntryStatus;
1789
									}
1790
								}
1788
								}
1791
							}
1789
							}
1792
						}
1790
						}
Lines 1813-1819 Link Here
1813
					}
1811
					}
1814
1812
1815
					// get validation status
1813
					// get validation status
1816
					IJavaModelStatus status = validateClasspathEntry(project, entry, checkSourceAttachment, recurseInContainers);
1814
					IJavaModelStatus status = validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/);
1817
					if (!status.isOK()) return status;
1815
					if (!status.isOK()) return status;
1818
1816
1819
					// return deprecation status if any
1817
					// return deprecation status if any
Lines 1836-1843 Link Here
1836
				for (int i = 0, length = chainedJars.length; i < length; i++) {
1834
				for (int i = 0, length = chainedJars.length; i < length; i++) {
1837
					IPath chainedJar = chainedJars[i];
1835
					IPath chainedJar = chainedJars[i];
1838
					IJavaModelStatus status = validateLibraryEntry(chainedJar, project, null/*don't check source attachment*/, null/*force computing of entryPathMsg*/);
1836
					IJavaModelStatus status = validateLibraryEntry(chainedJar, project, null/*don't check source attachment*/, null/*force computing of entryPathMsg*/);
1839
					if (!status.isOK())
1837
					if (!status.isOK()) {
1838
						if (referredByContainer && status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH)
1839
							continue; // ignore this entry (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=250946 )
1840
						return status;
1840
						return status;
1841
					}
1841
				}
1842
				}
1842
				
1843
				
1843
				IJavaModelStatus status = validateLibraryEntry(path, project, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg);
1844
				IJavaModelStatus status = validateLibraryEntry(path, project, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg);
(-)model/org/eclipse/jdt/internal/core/ClasspathValidation.java (-1 / +1 lines)
Lines 66-72 Link Here
66
66
67
		if (rawClasspath != JavaProject.INVALID_CLASSPATH && outputLocation != null) {
67
		if (rawClasspath != JavaProject.INVALID_CLASSPATH && outputLocation != null) {
68
		 	for (int i = 0; i < rawClasspath.length; i++) {
68
		 	for (int i = 0; i < rawClasspath.length; i++) {
69
				status = ClasspathEntry.validateClasspathEntry(this.project, rawClasspath[i], false/*src attach*/, true /*recurse in container*/);
69
				status = ClasspathEntry.validateClasspathEntry(this.project, rawClasspath[i], false/*src attach*/, false /*not referred by a container*/);
70
				if (!status.isOK()) {
70
				if (!status.isOK()) {
71
					if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) rawClasspath[i]).isOptional())
71
					if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) rawClasspath[i]).isOptional())
72
						continue; // ignore this entry
72
						continue; // ignore this entry
(-)model/org/eclipse/jdt/core/JavaConventions.java (-2 / +2 lines)
Lines 605-616 Link Here
605
	 *
605
	 *
606
	 * @param project the given java project
606
	 * @param project the given java project
607
	 * @param entry the given classpath entry
607
	 * @param entry the given classpath entry
608
	 * @param checkSourceAttachment a flag to determine if source attachement should be checked
608
	 * @param checkSourceAttachment a flag to determine if source attachment should be checked
609
	 * @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
609
	 * @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
610
	 * @since 2.0
610
	 * @since 2.0
611
	 */
611
	 */
612
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment){
612
	public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment){
613
		IJavaModelStatus status = ClasspathEntry.validateClasspathEntry(project, entry, checkSourceAttachment, true/*recurse in container*/);
613
		IJavaModelStatus status = ClasspathEntry.validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/);
614
		if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional())
614
		if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional())
615
			return JavaModelStatus.VERIFIED_OK;
615
			return JavaModelStatus.VERIFIED_OK;
616
		return status;
616
		return status;
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+26 lines)
Lines 3340-3345 Link Here
3340
	}
3340
	}
3341
}
3341
}
3342
/*
3342
/*
3343
 * Ensures that no marker is created for incorrect extra libraries in the Class-Path: clause of an external jar referenced by a container
3344
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=250946 )
3345
 */
3346
public void testExtraLibraries14() throws Exception {
3347
	try {
3348
		Util.createJar(
3349
			new String[0],
3350
			new String[] {
3351
				"META-INF/MANIFEST.MF",
3352
				"Manifest-Version: 1.0\n" +
3353
				"Class-Path: nonExisting.jar\n",
3354
			},
3355
			getExternalResourcePath("lib1.jar"),
3356
			JavaCore.VERSION_1_4);
3357
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", getExternalResourcePath("lib1.jar")}));
3358
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, "");
3359
		assertMarkers(
3360
			"Unexpected markers",
3361
			"",
3362
			p);
3363
	} finally {
3364
		deleteProject("P");
3365
		deleteExternalResource("lib1.jar");
3366
	}
3367
}
3368
/*
3343
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
3369
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
3344
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
3370
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
3345
 */
3371
 */
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-2 / +2 lines)
Lines 1756-1763 Link Here
1756
		return new File(getExternalPath(), relativePath);
1756
		return new File(getExternalPath(), relativePath);
1757
	}
1757
	}
1758
1758
1759
	protected String getExternalResourcePath(String name) {
1759
	protected String getExternalResourcePath(String relativePath) {
1760
		return getExternalPath() + name;
1760
		return getExternalPath() + relativePath;
1761
	}
1761
	}
1762
1762
1763
	/**
1763
	/**

Return to bug 250946