### 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.190 diff -u -r1.190 ClasspathTests.java --- src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 16 Oct 2008 14:30:32 -0000 1.190 +++ src/org/eclipse/jdt/core/tests/model/ClasspathTests.java 17 Oct 2008 09:30:09 -0000 @@ -3366,6 +3366,32 @@ } } /* + * Ensures that the extra libraries in the Class-Path: clause of a jar with a \r\n separator don't cause an exception + * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 ) + */ +public void testExtraLibraries15() throws Exception { + try { + Util.createJar( + new String[0], + new String[] { + "META-INF/MANIFEST.MF", + "Manifest-Version: 1.0\r\n" + + "Class-Path: \r\n" + + "\r\n", + }, + getExternalResourcePath("lib1.jar"), + JavaCore.VERSION_1_4); + ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", getExternalResourcePath("lib1.jar")})); + IJavaProject p = createJavaProject("P", new String[0], new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, ""); + assertClasspathEquals( + p.getResolvedClasspath(true), + ""+ getExternalPath() + "lib1.jar[CPE_LIBRARY][K_BINARY][isExported:false]" + ); + } finally { + deleteProject("P"); + deleteExternalResource("lib1.jar"); + } +}/* * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 ) */ Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v retrieving revision 1.225 diff -u -r1.225 AbstractJavaModelTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 16 Oct 2008 14:30:32 -0000 1.225 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 17 Oct 2008 09:30:08 -0000 @@ -995,15 +995,15 @@ assertStringsEqual(message, expected, strings); } protected void assertStringsEqual(String message, String expected, String[] strings) { - String actual = toString(strings, true/*add extra new lines*/); + String actual = org.eclipse.jdt.core.tests.util.Util.toString(strings, true/*add extra new lines*/); if (!expected.equals(actual)) { System.out.println(displayString(actual, this.tabs) + this.endChar); } assertEquals(message, expected, actual); } protected void assertStringsEqual(String message, String[] expectedStrings, String[] actualStrings) { - String expected = toString(expectedStrings, false/*don't add extra new lines*/); - String actual = toString(actualStrings, false/*don't add extra new lines*/); + String expected = org.eclipse.jdt.core.tests.util.Util.toString(expectedStrings, false/*don't add extra new lines*/); + String actual = org.eclipse.jdt.core.tests.util.Util.toString(actualStrings, false/*don't add extra new lines*/); if (!expected.equals(actual)) { System.out.println(displayString(actual, this.tabs) + this.endChar); } @@ -2774,17 +2774,7 @@ } protected String toString(String[] strings) { - return toString(strings, false/*don't add extra new line*/); - } - protected String toString(String[] strings, boolean addExtraNewLine) { - if (strings == null) return "null"; - StringBuffer buffer = new StringBuffer(); - for (int i = 0, length = strings.length; i < length; i++){ - buffer.append(strings[i]); - if (addExtraNewLine || i < length - 1) - buffer.append("\n"); - } - return buffer.toString(); + return org.eclipse.jdt.core.tests.util.Util.toString(strings, false/*don't add extra new line*/); } protected void tearDown() throws Exception { super.tearDown(); #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java,v retrieving revision 1.1 diff -u -r1.1 ManifestAnalyzer.java --- compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java 9 Oct 2008 08:13:08 -0000 1.1 +++ compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java 17 Oct 2008 09:30:10 -0000 @@ -36,6 +36,8 @@ this.calledFilesNames = null; for (;;) { currentChar = reader.read(); + if (currentChar == '\r') // skip \r, will consider \n later (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 ) + currentChar = reader.read(); switch (state) { case START: if (currentChar == -1) { @@ -102,7 +104,7 @@ case READING_JAR: if (currentChar == -1) { return false; - } else if (currentChar == '\n' || currentChar == '\r') { + } else if (currentChar == '\n') { // appends token below state = CONTINUING; } else if (currentChar == ' ') { #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v retrieving revision 1.177 diff -u -r1.177 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 10 Oct 2008 17:24:24 -0000 1.177 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Oct 2008 09:30:13 -0000 @@ -21,6 +21,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import junit.framework.Test; @@ -11026,4 +11027,20 @@ "", true); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 +public void test291_jar_ref_in_jar() throws Exception { + assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( + new StringReader( + "Manifest-Version: 1.0\r\n" + + "Created-By: Eclipse JDT Test Harness\r\n" + + "Class-Path: \r\n" + + "\r\n" + ))); + List calledFileNames = ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames(); + String actual = calledFileNames == null ? "" : Util.toString((String[]) calledFileNames.toArray(new String[calledFileNames.size()]), false/*don't add extra new lines*/); + assertStringEquals( + "", + actual, + true/*show line serators*/); +} } Index: src/org/eclipse/jdt/core/tests/util/Util.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v retrieving revision 1.72 diff -u -r1.72 Util.java --- src/org/eclipse/jdt/core/tests/util/Util.java 9 Oct 2008 11:55:19 -0000 1.72 +++ src/org/eclipse/jdt/core/tests/util/Util.java 17 Oct 2008 09:30:13 -0000 @@ -1022,6 +1022,16 @@ nativePath.substring(0, nativePath.length() - 1) : nativePath; } +public static String toString(String[] strings, boolean addExtraNewLine) { + if (strings == null) return "null"; + StringBuffer buffer = new StringBuffer(); + for (int i = 0, length = strings.length; i < length; i++){ + buffer.append(strings[i]); + if (addExtraNewLine || i < length - 1) + buffer.append("\n"); + } + return buffer.toString(); +} /** * Unzip the contents of the given zip in the given directory (create it if it doesn't exist) */