### Eclipse Workspace Patch 1.0 #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.194 diff -u -r1.194 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 8 Dec 2008 15:49:10 -0000 1.194 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 11 Dec 2008 14:42:43 -0000 @@ -164,6 +164,40 @@ return result; } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136, ignore class path errors from optional +// class path entries. + +public void test124117() throws CoreException { + + IJavaProject p = null; + try { + + p = this.createJavaProject("P0", new String[] {"src0", "src1"}, "bin0"); + IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.OPTIONAL, "true"); + JavaCore.setClasspathContainer( + new Path("container/default"), + new IJavaProject[]{ p }, + new IClasspathContainer[] { + new TestContainer(new Path("container/default"), + new IClasspathEntry[]{ + JavaCore.newLibraryEntry(new Path("/P0/JUNK"), new Path("/P0/SBlah"), new Path("/P0"), null, new IClasspathAttribute[] {attribute}, false)}) + }, + null); + + IClasspathEntry newClasspath = JavaCore.newContainerEntry(new Path("container/default")); + + IJavaModelStatus status = JavaConventions.validateClasspathEntry(p, newClasspath, true); + + assertStatus( + "should NOT have complained about missing library as it is optional", + "OK", + status); + + } finally { + deleteProject ("P0"); + } +} + /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=232816: Misleading problem text for missing jar in user * library. We now mention the container name in this and related diagnostics so the context and connection is clearer. * The bunch of tests with names of the form test232816*() test several paths in the function #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.110 diff -u -r1.110 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 8 Dec 2008 15:49:12 -0000 1.110 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 11 Dec 2008 14:42:47 -0000 @@ -1745,7 +1745,11 @@ * @return a java model status describing the problem related to this classpath entry if any, a status object with code IStatus.OK if the entry is fine */ public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment, boolean referredByContainer){ - return validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer); + IJavaModelStatus status = validateClasspathEntry(project, entry, null, checkSourceAttachment, referredByContainer); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136, ignore class path errors from optional entries. + if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional()) + return JavaModelStatus.VERIFIED_OK; + return status; } private static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, IClasspathContainer entryContainer, boolean checkSourceAttachment, boolean referredByContainer){ @@ -1860,6 +1864,9 @@ } } IJavaModelStatus status = validateLibraryEntry(path, project, containerInfo, checkSourceAttachment ? entry.getSourceAttachmentPath() : null, entryPathMsg); + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171136, ignore class path errors from optional entries + if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional()) + status = JavaModelStatus.VERIFIED_OK; if (!status.isOK()) return status; break; Index: model/org/eclipse/jdt/internal/core/ClasspathValidation.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathValidation.java,v retrieving revision 1.3 diff -u -r1.3 ClasspathValidation.java --- model/org/eclipse/jdt/internal/core/ClasspathValidation.java 16 Oct 2008 14:30:30 -0000 1.3 +++ model/org/eclipse/jdt/internal/core/ClasspathValidation.java 11 Dec 2008 14:42:47 -0000 @@ -14,7 +14,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaModelStatus; -import org.eclipse.jdt.core.IJavaModelStatusConstants; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.core.builder.JavaBuilder; @@ -68,8 +67,6 @@ for (int i = 0; i < rawClasspath.length; i++) { status = ClasspathEntry.validateClasspathEntry(this.project, rawClasspath[i], false/*src attach*/, false /*not referred by a container*/); if (!status.isOK()) { - if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) rawClasspath[i]).isOptional()) - continue; // ignore this entry this.project.createClasspathProblemMarker(status); } } Index: model/org/eclipse/jdt/core/JavaConventions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java,v retrieving revision 1.121 diff -u -r1.121 JavaConventions.java --- model/org/eclipse/jdt/core/JavaConventions.java 16 Oct 2008 14:30:30 -0000 1.121 +++ model/org/eclipse/jdt/core/JavaConventions.java 11 Dec 2008 14:42:46 -0000 @@ -610,10 +610,7 @@ * @since 2.0 */ public static IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment){ - IJavaModelStatus status = ClasspathEntry.validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/); - if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) entry).isOptional()) - return JavaModelStatus.VERIFIED_OK; - return status; + return ClasspathEntry.validateClasspathEntry(project, entry, checkSourceAttachment, false/*not referred by container*/); } /**