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

(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (+26 lines)
Lines 3366-3371 Link Here
3366
	}
3366
	}
3367
}
3367
}
3368
/*
3368
/*
3369
 * Ensures that the extra libraries in the Class-Path: clause of a jar with a \r\n separator don't cause an exception
3370
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 )
3371
 */
3372
public void testExtraLibraries15() throws Exception {
3373
	try {
3374
		Util.createJar(
3375
			new String[0],
3376
			new String[] {
3377
				"META-INF/MANIFEST.MF",
3378
				"Manifest-Version: 1.0\r\n" +
3379
				"Class-Path: \r\n" +
3380
				"\r\n",
3381
			},
3382
			getExternalResourcePath("lib1.jar"),
3383
			JavaCore.VERSION_1_4);
3384
		ContainerInitializer.setInitializer(new DefaultContainerInitializer(new String[] {"P", getExternalResourcePath("lib1.jar")}));
3385
		IJavaProject p = createJavaProject("P", new String[0], new String[] {"org.eclipse.jdt.core.tests.model.TEST_CONTAINER"}, "");
3386
		assertClasspathEquals(
3387
			p.getResolvedClasspath(true), 
3388
			""+ getExternalPath() + "lib1.jar[CPE_LIBRARY][K_BINARY][isExported:false]"
3389
		);
3390
	} finally {
3391
		deleteProject("P");
3392
		deleteExternalResource("lib1.jar");
3393
	}
3394
}/*
3369
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
3395
 * Ensures that a marker is removed if adding an internal jar that is on the classpath in another project
3370
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
3396
 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=213723 )
3371
 */
3397
 */
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (-14 / +4 lines)
Lines 995-1009 Link Here
995
		assertStringsEqual(message, expected, strings);
995
		assertStringsEqual(message, expected, strings);
996
	}
996
	}
997
	protected void assertStringsEqual(String message, String expected, String[] strings) {
997
	protected void assertStringsEqual(String message, String expected, String[] strings) {
998
		String actual = toString(strings, true/*add extra new lines*/);
998
		String actual = org.eclipse.jdt.core.tests.util.Util.toString(strings, true/*add extra new lines*/);
999
		if (!expected.equals(actual)) {
999
		if (!expected.equals(actual)) {
1000
			System.out.println(displayString(actual, this.tabs) + this.endChar);
1000
			System.out.println(displayString(actual, this.tabs) + this.endChar);
1001
		}
1001
		}
1002
		assertEquals(message, expected, actual);
1002
		assertEquals(message, expected, actual);
1003
	}
1003
	}
1004
	protected void assertStringsEqual(String message, String[] expectedStrings, String[] actualStrings) {
1004
	protected void assertStringsEqual(String message, String[] expectedStrings, String[] actualStrings) {
1005
		String expected = toString(expectedStrings, false/*don't add extra new lines*/);
1005
		String expected = org.eclipse.jdt.core.tests.util.Util.toString(expectedStrings, false/*don't add extra new lines*/);
1006
		String actual = toString(actualStrings, false/*don't add extra new lines*/);
1006
		String actual = org.eclipse.jdt.core.tests.util.Util.toString(actualStrings, false/*don't add extra new lines*/);
1007
		if (!expected.equals(actual)) {
1007
		if (!expected.equals(actual)) {
1008
			System.out.println(displayString(actual, this.tabs) + this.endChar);
1008
			System.out.println(displayString(actual, this.tabs) + this.endChar);
1009
		}
1009
		}
Lines 2774-2790 Link Here
2774
	}
2774
	}
2775
2775
2776
	protected String toString(String[] strings) {
2776
	protected String toString(String[] strings) {
2777
		return toString(strings, false/*don't add extra new line*/);
2777
		return org.eclipse.jdt.core.tests.util.Util.toString(strings, false/*don't add extra new line*/);
2778
	}
2779
	protected String toString(String[] strings, boolean addExtraNewLine) {
2780
		if (strings == null) return "null";
2781
		StringBuffer buffer = new StringBuffer();
2782
		for (int i = 0, length = strings.length; i < length; i++){
2783
			buffer.append(strings[i]);
2784
			if (addExtraNewLine || i < length - 1)
2785
				buffer.append("\n");
2786
		}
2787
		return buffer.toString();
2788
	}
2778
	}
2789
	protected void tearDown() throws Exception {
2779
	protected void tearDown() throws Exception {
2790
		super.tearDown();
2780
		super.tearDown();
(-)compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java (-1 / +3 lines)
Lines 36-41 Link Here
36
		this.calledFilesNames = null;
36
		this.calledFilesNames = null;
37
		for (;;) {
37
		for (;;) {
38
			currentChar = reader.read();
38
			currentChar = reader.read();
39
			if (currentChar == '\r')  // skip \r, will consider \n later (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 )
40
				currentChar = reader.read();
39
			switch (state) {
41
			switch (state) {
40
				case START:
42
				case START:
41
					if (currentChar == -1) {
43
					if (currentChar == -1) {
Lines 102-108 Link Here
102
				case READING_JAR:
104
				case READING_JAR:
103
					if (currentChar == -1) {
105
					if (currentChar == -1) {
104
						return false;
106
						return false;
105
					} else if (currentChar == '\n' || currentChar == '\r') {
107
					} else if (currentChar == '\n') {
106
						// appends token below
108
						// appends token below
107
						state = CONTINUING;
109
						state = CONTINUING;
108
					} else if (currentChar == ' ') {
110
					} else if (currentChar == ' ') {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+17 lines)
Lines 21-26 Link Here
21
import java.text.MessageFormat;
21
import java.text.MessageFormat;
22
import java.util.ArrayList;
22
import java.util.ArrayList;
23
import java.util.Iterator;
23
import java.util.Iterator;
24
import java.util.List;
24
25
25
import junit.framework.Test;
26
import junit.framework.Test;
26
27
Lines 11026-11029 Link Here
11026
		"",
11027
		"",
11027
		true);
11028
		true);
11028
}
11029
}
11030
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 
11031
public void test291_jar_ref_in_jar() throws Exception {
11032
	assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents(
11033
		new StringReader(
11034
			"Manifest-Version: 1.0\r\n" +
11035
			"Created-By: Eclipse JDT Test Harness\r\n" +
11036
			"Class-Path: \r\n" +
11037
			"\r\n"
11038
		)));
11039
	List calledFileNames = ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames();
11040
	String actual = calledFileNames == null ? "<null>" : Util.toString((String[]) calledFileNames.toArray(new String[calledFileNames.size()]), false/*don't add extra new lines*/);
11041
	assertStringEquals(
11042
		"<null>", 
11043
		actual, 
11044
		true/*show line serators*/);
11045
}
11029
}
11046
}
(-)src/org/eclipse/jdt/core/tests/util/Util.java (+10 lines)
Lines 1022-1027 Link Here
1022
            nativePath.substring(0, nativePath.length() - 1) :
1022
            nativePath.substring(0, nativePath.length() - 1) :
1023
            nativePath;
1023
            nativePath;
1024
}
1024
}
1025
public static String toString(String[] strings, boolean addExtraNewLine) {
1026
	if (strings == null) return "null";
1027
	StringBuffer buffer = new StringBuffer();
1028
	for (int i = 0, length = strings.length; i < length; i++){
1029
		buffer.append(strings[i]);
1030
		if (addExtraNewLine || i < length - 1)
1031
			buffer.append("\n");
1032
	}
1033
	return buffer.toString();
1034
}
1025
/**
1035
/**
1026
 * Unzip the contents of the given zip in the given directory (create it if it doesn't exist)
1036
 * Unzip the contents of the given zip in the given directory (create it if it doesn't exist)
1027
 */
1037
 */

Return to bug 251079