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

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java (-1 / +1 lines)
Lines 51-57 Link Here
51
	try {
51
	try {
52
		initialize();
52
		initialize();
53
		ArrayList result = new ArrayList();
53
		ArrayList result = new ArrayList();
54
		ZipEntry manifest =	this.zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
54
		ZipEntry manifest = this.zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
55
		if (manifest != null) { // non-null implies regular file
55
		if (manifest != null) { // non-null implies regular file
56
			reader = new BufferedReader(new InputStreamReader(this.zipFile.getInputStream(manifest)));
56
			reader = new BufferedReader(new InputStreamReader(this.zipFile.getInputStream(manifest)));
57
			ManifestAnalyzer analyzer = new ManifestAnalyzer();
57
			ManifestAnalyzer analyzer = new ManifestAnalyzer();
(-)compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java (-8 / +33 lines)
Lines 70-85 Link Here
70
					break;
70
					break;
71
				case SKIPPING_WHITESPACE:
71
				case SKIPPING_WHITESPACE:
72
					if (currentChar == -1) {
72
					if (currentChar == -1) {
73
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
74
						addCurrentTokenJarWhenNecessary(currentJarToken);
73
						return true;
75
						return true;
74
					} else if (currentChar == '\n') {
76
					} else if (currentChar == '\n') {
75
						state = CONTINUING;
77
						state = CONTINUING;
76
					} else if (currentChar != ' ') {
78
					} else if (currentChar != ' ') {
77
						currentJarToken.append((char) currentChar);
79
						currentJarToken.append((char) currentChar);
78
						state = READING_JAR;
80
						state = READING_JAR;
81
					} else {
82
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
83
						addCurrentTokenJarWhenNecessary(currentJarToken);
79
					}
84
					}
80
					break;
85
					break;
81
				case CONTINUING:
86
				case CONTINUING:
82
					if (currentChar == -1) {
87
					if (currentChar == -1) {
88
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
89
						addCurrentTokenJarWhenNecessary(currentJarToken);
83
						return true;
90
						return true;
84
					} else if (currentChar == '\n') {
91
					} else if (currentChar == '\n') {
85
						state = START;
92
						state = START;
Lines 89-96 Link Here
89
						state = IN_CLASSPATH_HEADER;
96
						state = IN_CLASSPATH_HEADER;
90
						substate = 1;
97
						substate = 1;
91
					} else if (this.calledFilesNames == null) {
98
					} else if (this.calledFilesNames == null) {
92
						return false;
99
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
100
						return addCurrentTokenJarWhenNecessary(currentJarToken);
93
					} else {
101
					} else {
102
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
103
						addCurrentTokenJarWhenNecessary(currentJarToken);
94
						state = SKIP_LINE;
104
						state = SKIP_LINE;
95
					}
105
					}
96
					break;
106
					break;
Lines 101-112 Link Here
101
						state = START;
111
						state = START;
102
					}
112
					}
103
					break;
113
					break;
104
				case READING_JAR:
114
				case READING_JAR:	
105
					if (currentChar == -1) {
115
					if (currentChar == -1) {
106
						return false;
116
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
117
						return addCurrentTokenJarWhenNecessary(currentJarToken);
107
					} else if (currentChar == '\n') {
118
					} else if (currentChar == '\n') {
108
						// appends token below
119
						// appends token below
109
						state = CONTINUING;
120
						state = CONTINUING;
121
						// >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line
122
						break;
110
					} else if (currentChar == ' ') {
123
					} else if (currentChar == ' ') {
111
						// appends token below
124
						// appends token below
112
						state = SKIPPING_WHITESPACE;
125
						state = SKIPPING_WHITESPACE;
Lines 114-128 Link Here
114
						currentJarToken.append((char) currentChar);
127
						currentJarToken.append((char) currentChar);
115
						break;
128
						break;
116
					}
129
					}
117
					if (this.calledFilesNames == null) {
130
					addCurrentTokenJarWhenNecessary(currentJarToken);
118
						this.calledFilesNames = new ArrayList();
119
					}
120
					this.calledFilesNames.add(currentJarToken.toString());
121
					currentJarToken.setLength(0);
122
					break;
131
					break;
123
			}
132
			}
124
		}
133
		}
134
	}	
135
136
	// >>>>>>>>>>>>>>>> Method Extracted from analyzeManifestContents in the READING_JAR Block
137
	private boolean addCurrentTokenJarWhenNecessary(StringBuffer currentJarToken) {
138
		if (currentJarToken != null && currentJarToken.length() > 0) {
139
			if (this.calledFilesNames == null) {
140
				this.calledFilesNames = new ArrayList();
141
			}
142
			this.calledFilesNames.add(currentJarToken.toString());
143
			currentJarToken.setLength(0);
144
			return true;
145
		}
146
		return false;
125
	}
147
	}
148
	// <<<<<<<<<<<<<<<<<<<<<<
149
150
126
	public int getClasspathSectionsCount() {
151
	public int getClasspathSectionsCount() {
127
		return this.ClasspathSectionsCount;
152
		return this.ClasspathSectionsCount;
128
	}
153
	}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java (+1 lines)
Lines 70-75 Link Here
70
	standardTests.add(SerialVersionUIDTests.class);
70
	standardTests.add(SerialVersionUIDTests.class);
71
	standardTests.add(LineNumberAttributeTest.class);
71
	standardTests.add(LineNumberAttributeTest.class);
72
	standardTests.add(ProgrammingProblemsTest.class);
72
	standardTests.add(ProgrammingProblemsTest.class);
73
	standardTests.add(ManifestAnalyzerTest.class);
73
74
74
	// add all javadoc tests
75
	// add all javadoc tests
75
	for (int i=0, l=JavadocTest.ALL_CLASSES.size(); i<l; i++) {
76
	for (int i=0, l=JavadocTest.ALL_CLASSES.size(); i<l; i++) {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java (+107 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Fabrice Matrat - initial contribution
10
 *     IBM Corporation - code review and integration
11
 *******************************************************************************/
12
package org.eclipse.jdt.core.tests.compiler.regression;
13
import java.io.IOException;
14
import java.io.StringReader;
15
import java.util.List;
16
17
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
18
19
public class ManifestAnalyzerTest extends AbstractRegressionTest {
20
21
	private static final String FIRST_JAR = "firstJar.jar";
22
	private static final String SECOND_JAR = "secondJar.jar";
23
	private static final String WHITESPACE = " ";
24
25
	ManifestAnalyzer manifestAnalyzer = new ManifestAnalyzer();
26
27
	public ManifestAnalyzerTest(String name) {
28
		super(name);
29
	}
30
	public void testWithOneJar() throws IOException {
31
		String testWithOneJar = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\nBuild-Reference: Version toto";
32
		StringReader reader = new StringReader(testWithOneJar);
33
		this.manifestAnalyzer.analyzeManifestContents(reader);
34
		List jars = this.manifestAnalyzer.getCalledFileNames();
35
		assertEquals("Wrong size", 1, jars.size());
36
		assertEquals(FIRST_JAR, jars.get(0));
37
	}
38
39
	public void testWithOneJarWithWiteSpace() throws IOException {
40
		String testWithOneJarWithWiteSpace = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "\nBuild-Reference: Version toto";
41
		StringReader reader = new StringReader(testWithOneJarWithWiteSpace);
42
		this.manifestAnalyzer.analyzeManifestContents(reader);
43
		List jars = this.manifestAnalyzer.getCalledFileNames();
44
		assertEquals("Wrong size", 1, jars.size());
45
		assertEquals(FIRST_JAR, jars.get(0));
46
	}
47
48
	public void testWithSecondJarOnNextLine() throws IOException {
49
		String testWithSecondJarOnNextLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n"+ WHITESPACE + WHITESPACE +"secondJar.jar\nBuild-Reference: Version toto";
50
		StringReader reader = new StringReader(testWithSecondJarOnNextLine);
51
		this.manifestAnalyzer.analyzeManifestContents(reader);
52
		List jars = this.manifestAnalyzer.getCalledFileNames();
53
		assertEquals("Wrong size", 2, jars.size());
54
		assertEquals(FIRST_JAR, jars.get(0));
55
		assertEquals(SECOND_JAR, jars.get(1));
56
	}
57
58
	public void testWithSecondJarOnTwoLine() throws IOException {
59
		String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
60
		StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
61
		this.manifestAnalyzer.analyzeManifestContents(reader);
62
		List jars = this.manifestAnalyzer.getCalledFileNames();
63
		assertEquals("Wrong size", 2, jars.size());
64
		assertEquals(FIRST_JAR, jars.get(0));
65
		assertEquals(SECOND_JAR, jars.get(1));
66
	}
67
68
	public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException {
69
		String testWithSecondJarOnTwoLineEndedWithEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar";
70
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF);
71
		this.manifestAnalyzer.analyzeManifestContents(reader);
72
		List jars = this.manifestAnalyzer.getCalledFileNames();
73
		assertEquals("Wrong size", 2, jars.size());
74
		assertEquals(FIRST_JAR, jars.get(0));
75
		assertEquals(SECOND_JAR, jars.get(1));
76
	}
77
78
	public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException {
79
		String testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar ";
80
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF);
81
		this.manifestAnalyzer.analyzeManifestContents(reader);
82
		List jars = this.manifestAnalyzer.getCalledFileNames();
83
		assertEquals("Wrong size", 2, jars.size());
84
		assertEquals(FIRST_JAR, jars.get(0));
85
		assertEquals(SECOND_JAR, jars.get(1));
86
	}
87
88
	public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException {
89
		String testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar \n";
90
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF);
91
		this.manifestAnalyzer.analyzeManifestContents(reader);
92
		List jars = this.manifestAnalyzer.getCalledFileNames();
93
		assertEquals("Wrong size", 2, jars.size());
94
		assertEquals(FIRST_JAR, jars.get(0));
95
		assertEquals(SECOND_JAR, jars.get(1));
96
	}
97
98
	public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException {
99
		String testWithSecondJarOnTwoLineEndedWithNewLineEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar\n";
100
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithNewLineEOF);
101
		this.manifestAnalyzer.analyzeManifestContents(reader);
102
		List jars = this.manifestAnalyzer.getCalledFileNames();
103
		assertEquals("Wrong size", 2, jars.size());
104
		assertEquals(FIRST_JAR, jars.get(0));
105
		assertEquals(SECOND_JAR, jars.get(1));
106
	}
107
}

Return to bug 265103