### 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.124 diff -u -r1.124 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 2 Mar 2010 06:46:00 -0000 1.124 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 7 Apr 2010 05:23:46 -0000 @@ -931,6 +931,13 @@ } } else { IPath calledJar = directoryPath.append(new Path(calledFileName)); + // Ignore if segment count is Zero (https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150) + if (calledJar.segmentCount() == 0) { + if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { + Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ + } + continue; + } resolvedChainedLibraries(calledJar, visited, result); result.add(calledJar); } #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.210 diff -u -r1.210 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 29 Mar 2010 05:33:57 -0000 1.210 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 7 Apr 2010 05:23:51 -0000 @@ -6641,5 +6641,50 @@ this.deleteProject("P"); } } +/** + * @bug 308150: JAR with invalid Class-Path entry in MANIFEST.MF crashes the project + * Test that an invalid referenced library entry in the Class-Path of the MANIFEST doesn't + * create any exceptions and is NOT added to the resolved classpath. + * + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150" + * @throws Exception + */ +public void testBug308150() throws Exception { + try { + + IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin"); + IClasspathEntry[] classpath = new IClasspathEntry[2]; + + // The Class-Path references an entry that points to the workspace root (hence invalid) + addLibrary(proj, "invalid.jar", null, new String[0], + new String[] { + "META-INF/MANIFEST.MF", + "Manifest-Version: 1.0\n" + + "Class-Path: ../..\n", + }, + JavaCore.VERSION_1_4); + + addExternalLibrary(proj, getExternalResourcePath("invalid2.jar"), new String[0], + new String[] { + "META-INF/MANIFEST.MF", + "Manifest-Version: 1.0\n" + + "Class-Path: ../..\n", + }, + JavaCore.VERSION_1_4); + refreshExternalArchives(proj); + + classpath[0] = JavaCore.newLibraryEntry(new Path("/P/invalid.jar"), null, null); + classpath[1] = JavaCore.newLibraryEntry(new Path(getExternalResourcePath("invalid2.jar")), null, null); + proj.setRawClasspath(classpath, null); + waitForAutoBuild(); + IClasspathEntry[] resolvedClasspath = proj.getResolvedClasspath(true); + + assertClasspathEquals(resolvedClasspath, + "/P/invalid.jar[CPE_LIBRARY][K_BINARY][isExported:false]\n" + + ""+ getExternalPath() + "invalid2.jar[CPE_LIBRARY][K_BINARY][isExported:false]"); + } finally { + this.deleteProject("P"); + } +} }