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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (+7 lines)
Lines 931-936 Link Here
931
					}
931
					}
932
				} else {
932
				} else {
933
					IPath calledJar = directoryPath.append(new Path(calledFileName));
933
					IPath calledJar = directoryPath.append(new Path(calledFileName));
934
					// Ignore if segment count is Zero (https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150)
935
					if (calledJar.segmentCount() == 0) {
936
						if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
937
							Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
938
						}
939
						return;
940
					}
934
					resolvedChainedLibraries(calledJar, visited, result);
941
					resolvedChainedLibraries(calledJar, visited, result);
935
					result.add(calledJar);
942
					result.add(calledJar);
936
				}
943
				}
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+45 lines)
Lines 6641-6645 Link Here
6641
			this.deleteProject("P");
6641
			this.deleteProject("P");
6642
	}
6642
	}
6643
}
6643
}
6644
/**
6645
 * @bug 308150: JAR with invalid Class-Path entry in MANIFEST.MF crashes the project
6646
 * Test that an invalid referenced library entry in the Class-Path of the MANIFEST doesn't
6647
 * create any exceptions and is NOT added to the resolved classpath.
6648
 *  
6649
 *  @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150"
6650
 * @throws Exception
6651
 */
6652
public void testBug308150() throws Exception {
6653
	try {
6654
6655
		IJavaProject proj = this.createJavaProject("P", new String[] {}, "bin");
6656
		IClasspathEntry[] classpath = new IClasspathEntry[2];
6657
6658
		// The Class-Path references an entry that points to the workspace root (hence invalid)
6659
		addLibrary(proj, "invalid.jar", null, new String[0], 
6660
				new String[] {
6661
					"META-INF/MANIFEST.MF",
6662
					"Manifest-Version: 1.0\n" +
6663
					"Class-Path: ../..\n",
6664
				},
6665
				JavaCore.VERSION_1_4);
6666
6667
		addExternalLibrary(proj, getExternalResourcePath("invalid2.jar"), new String[0], 
6668
				new String[] {
6669
					"META-INF/MANIFEST.MF",
6670
					"Manifest-Version: 1.0\n" +
6671
					"Class-Path: ../..\n",
6672
				},
6673
				JavaCore.VERSION_1_4);
6674
			refreshExternalArchives(proj);
6675
6676
		classpath[0] = JavaCore.newLibraryEntry(new Path("/P/invalid.jar"), null, null);
6677
		classpath[1] = JavaCore.newLibraryEntry(new Path(getExternalResourcePath("invalid2.jar")), null, null);
6678
		proj.setRawClasspath(classpath, null);
6679
		waitForAutoBuild();
6680
		IClasspathEntry[] resolvedClasspath = proj.getResolvedClasspath(true);
6681
6682
		assertClasspathEquals(resolvedClasspath, 
6683
				"/P/invalid.jar[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6684
				""+ getExternalPath() + "invalid2.jar[CPE_LIBRARY][K_BINARY][isExported:false]");
6685
	} finally {
6686
		this.deleteProject("P");
6687
	}
6688
}
6644
6689
6645
}
6690
}

Return to bug 308150