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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-36 / +35 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import java.io.BufferedReader;
14
import java.io.ByteArrayOutputStream;
13
import java.io.ByteArrayOutputStream;
15
import java.io.File;
14
import java.io.File;
16
import java.io.IOException;
15
import java.io.IOException;
17
import java.io.InputStreamReader;
16
import java.io.InputStream;
18
import java.io.OutputStreamWriter;
17
import java.io.OutputStreamWriter;
19
import java.io.UnsupportedEncodingException;
18
import java.io.UnsupportedEncodingException;
20
import java.util.ArrayList;
19
import java.util.ArrayList;
Lines 49-56 Link Here
49
import org.eclipse.jdt.core.compiler.CharOperation;
48
import org.eclipse.jdt.core.compiler.CharOperation;
50
import org.eclipse.jdt.core.compiler.IProblem;
49
import org.eclipse.jdt.core.compiler.IProblem;
51
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
50
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
52
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
53
import org.eclipse.jdt.internal.compiler.env.AccessRule;
51
import org.eclipse.jdt.internal.compiler.env.AccessRule;
52
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
54
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
53
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
55
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
54
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
56
import org.eclipse.jdt.internal.core.util.Messages;
55
import org.eclipse.jdt.internal.core.util.Messages;
Lines 904-910 Link Here
904
			return null;
903
			return null;
905
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
904
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
906
		ZipFile zip = null;
905
		ZipFile zip = null;
907
		BufferedReader reader = null;
906
		InputStream inputStream = null;
908
		List calledFileNames = null;
907
		List calledFileNames = null;
909
		try {
908
		try {
910
			zip = manager.getZipFile(jarPath);
909
			zip = manager.getZipFile(jarPath);
Lines 912-920 Link Here
912
			if (manifest == null) 
911
			if (manifest == null) 
913
				return null;
912
				return null;
914
			// non-null implies regular file
913
			// non-null implies regular file
915
			reader = new BufferedReader(new InputStreamReader(zip.getInputStream(manifest)));
916
			ManifestAnalyzer analyzer = new ManifestAnalyzer();
914
			ManifestAnalyzer analyzer = new ManifestAnalyzer();
917
			boolean success = analyzer.analyzeManifestContents(reader);
915
			inputStream = zip.getInputStream(manifest);
916
			boolean success = analyzer.analyzeManifestContents(inputStream);
918
			calledFileNames = analyzer.getCalledFileNames();
917
			calledFileNames = analyzer.getCalledFileNames();
919
			if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) {
918
			if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) {
920
				if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
919
				if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) {
Lines 941-949 Link Here
941
			}
940
			}
942
		} finally {
941
		} finally {
943
			manager.closeZipFile(zip);
942
			manager.closeZipFile(zip);
944
			if (reader != null) {
943
			if (inputStream != null) {
945
				try {
944
				try {
946
					reader.close();
945
					inputStream.close();
947
				} catch (IOException e) {
946
				} catch (IOException e) {
948
					// best effort
947
					// best effort
949
				}
948
				}
Lines 1462-1468 Link Here
1462
	 *   <li> The project output location path cannot be null, must be absolute and located inside the project.
1461
	 *   <li> The project output location path cannot be null, must be absolute and located inside the project.
1463
	 *   <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project,
1462
	 *   <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project,
1464
	 *   <li> A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
1463
	 *   <li> A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself).
1465
     *   <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below:
1464
	 *   <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below:
1466
	 *      <ul><li> A source folder can coincidate with its own output location, in which case this output can then contain library archives.
1465
	 *      <ul><li> A source folder can coincidate with its own output location, in which case this output can then contain library archives.
1467
	 *                     However, a specific output location cannot coincidate with any library or a distinct source folder than the one referring to it. </li>
1466
	 *                     However, a specific output location cannot coincidate with any library or a distinct source folder than the one referring to it. </li>
1468
	 *              <li> A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one. </li>
1467
	 *              <li> A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one. </li>
Lines 1581-1588 Link Here
1581
		}
1580
		}
1582
		// check nesting across output locations
1581
		// check nesting across output locations
1583
		for (int i = 1 /*no check for default output*/ ; i < outputCount; i++) {
1582
		for (int i = 1 /*no check for default output*/ ; i < outputCount; i++) {
1584
		    IPath customOutput = outputLocations[i];
1583
			IPath customOutput = outputLocations[i];
1585
		    int index;
1584
			int index;
1586
			// check nesting
1585
			// check nesting
1587
			if ((index = Util.indexOfEnclosingPath(customOutput, outputLocations, outputCount)) != -1 && index != i) {
1586
			if ((index = Util.indexOfEnclosingPath(customOutput, outputLocations, outputCount)) != -1 && index != i) {
1588
				if (index == 0) {
1587
				if (index == 0) {
Lines 1681-1706 Link Here
1681
			}
1680
			}
1682
1681
1683
			// prevent nesting output location inside entry unless enclosing is a source entry which explicitly exclude the output location
1682
			// prevent nesting output location inside entry unless enclosing is a source entry which explicitly exclude the output location
1684
		    char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
1683
			char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars();
1685
		    char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
1684
			char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
1686
		    for (int j = 0; j < outputCount; j++){
1685
			for (int j = 0; j < outputCount; j++){
1687
		        IPath currentOutput = outputLocations[j];
1686
				IPath currentOutput = outputLocations[j];
1688
    			if (entryPath.equals(currentOutput)) continue;
1687
				if (entryPath.equals(currentOutput)) continue;
1689
				if (entryPath.isPrefixOf(currentOutput)) {
1688
				if (entryPath.isPrefixOf(currentOutput)) {
1690
				    if (kind != IClasspathEntry.CPE_SOURCE || !Util.isExcluded(currentOutput, inclusionPatterns, exclusionPatterns, true)) {
1689
				    if (kind != IClasspathEntry.CPE_SOURCE || !Util.isExcluded(currentOutput, inclusionPatterns, exclusionPatterns, true)) {
1691
						return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInEntry, new String[] {currentOutput.makeRelative().toString(), entryPath.makeRelative().toString()}));
1690
						return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInEntry, new String[] {currentOutput.makeRelative().toString(), entryPath.makeRelative().toString()}));
1692
				    }
1691
				    }
1693
				}
1692
				}
1694
		    }
1693
			}
1695
1694
1696
		    // prevent nesting entry inside output location - when distinct from project or a source folder
1695
			// prevent nesting entry inside output location - when distinct from project or a source folder
1697
		    for (int j = 0; j < outputCount; j++){
1696
			for (int j = 0; j < outputCount; j++){
1698
		        if (allowNestingInOutputLocations[j]) continue;
1697
				if (allowNestingInOutputLocations[j]) continue;
1699
		        IPath currentOutput = outputLocations[j];
1698
				IPath currentOutput = outputLocations[j];
1700
				if (currentOutput.isPrefixOf(entryPath)) {
1699
				if (currentOutput.isPrefixOf(entryPath)) {
1701
					return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInOutput, new String[] {entryPath.makeRelative().toString(), currentOutput.makeRelative().toString()}));
1700
					return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInOutput, new String[] {entryPath.makeRelative().toString(), currentOutput.makeRelative().toString()}));
1702
				}
1701
				}
1703
		    }
1702
			}
1704
		}
1703
		}
1705
		// ensure that no specific output is coincidating with another source folder (only allowed if matching current source folder)
1704
		// ensure that no specific output is coincidating with another source folder (only allowed if matching current source folder)
1706
		// 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate)
1705
		// 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate)
Lines 1921-1927 Link Here
1921
			// project source folder
1920
			// project source folder
1922
			case IClasspathEntry.CPE_SOURCE :
1921
			case IClasspathEntry.CPE_SOURCE :
1923
				if (((entry.getInclusionPatterns() != null && entry.getInclusionPatterns().length > 0)
1922
				if (((entry.getInclusionPatterns() != null && entry.getInclusionPatterns().length > 0)
1924
				        	|| (entry.getExclusionPatterns() != null && entry.getExclusionPatterns().length > 0))
1923
						|| (entry.getExclusionPatterns() != null && entry.getExclusionPatterns().length > 0))
1925
						&& JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) {
1924
						&& JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) {
1926
					return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, project, path);
1925
					return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, project, path);
1927
				}
1926
				}
Lines 2014-2034 Link Here
2014
				}
2013
				}
2015
			} else if (target instanceof File){
2014
			} else if (target instanceof File){
2016
				File file = JavaModel.getFile(target);
2015
				File file = JavaModel.getFile(target);
2017
			    if (file == null) {
2016
				if (file == null) {
2018
			    	if (container != null) {
2017
					if (container != null) {
2019
			    		return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container}));
2018
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container}));
2020
			    	} else {
2019
					} else {
2021
			    		return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
2020
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()}));
2022
			    	}
2021
					}
2023
			    } else if (sourceAttachment != null
2022
				} else if (sourceAttachment != null
2024
						&& !sourceAttachment.isEmpty()
2023
						&& !sourceAttachment.isEmpty()
2025
						&& JavaModel.getTarget(sourceAttachment, true) == null){
2024
						&& JavaModel.getTarget(sourceAttachment, true) == null){
2026
			    		if (container != null) {
2025
					if (container != null) {
2027
			    			return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container}));
2026
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container}));
2028
			    		} else {
2027
					} else {
2029
			    			return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
2028
						return  new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()}));
2030
			    		}
2029
					}
2031
			    	}
2030
				}
2032
			} else {
2031
			} else {
2033
				boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists();
2032
				boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists();
2034
				if (isExternal) {
2033
				if (isExternal) {
(-)batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java (-7 / +6 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.batch;
11
package org.eclipse.jdt.internal.compiler.batch;
12
12
13
import java.io.BufferedReader;
14
import java.io.File;
13
import java.io.File;
15
import java.io.IOException;
14
import java.io.IOException;
16
import java.io.InputStreamReader;
15
import java.io.InputStream;
17
import java.util.ArrayList;
16
import java.util.ArrayList;
18
import java.util.Enumeration;
17
import java.util.Enumeration;
19
import java.util.Hashtable;
18
import java.util.Hashtable;
Lines 47-61 Link Here
47
public List fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) {
46
public List fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) {
48
	// expected to be called once only - if multiple calls desired, consider
47
	// expected to be called once only - if multiple calls desired, consider
49
	// using a cache
48
	// using a cache
50
	BufferedReader reader = null;
49
	InputStream inputStream = null;
51
	try {
50
	try {
52
		initialize();
51
		initialize();
53
		ArrayList result = new ArrayList();
52
		ArrayList result = new ArrayList();
54
		ZipEntry manifest = this.zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
53
		ZipEntry manifest = this.zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$
55
		if (manifest != null) { // non-null implies regular file
54
		if (manifest != null) { // non-null implies regular file
56
			reader = new BufferedReader(new InputStreamReader(this.zipFile.getInputStream(manifest)));
55
			inputStream = this.zipFile.getInputStream(manifest);
57
			ManifestAnalyzer analyzer = new ManifestAnalyzer();
56
			ManifestAnalyzer analyzer = new ManifestAnalyzer();
58
			boolean success = analyzer.analyzeManifestContents(reader);
57
			boolean success = analyzer.analyzeManifestContents(inputStream);
59
			List calledFileNames = analyzer.getCalledFileNames();
58
			List calledFileNames = analyzer.getCalledFileNames();
60
			if (problemReporter != null) {
59
			if (problemReporter != null) {
61
				if (!success || analyzer.getClasspathSectionsCount() == 1 &&  calledFileNames == null) {
60
				if (!success || analyzer.getClasspathSectionsCount() == 1 &&  calledFileNames == null) {
Lines 78-86 Link Here
78
	} catch (IOException e) {
77
	} catch (IOException e) {
79
		return null;
78
		return null;
80
	} finally {
79
	} finally {
81
		if (reader != null) {
80
		if (inputStream != null) {
82
			try {
81
			try {
83
				reader.close();
82
				inputStream.close();
84
			} catch (IOException e) {
83
			} catch (IOException e) {
85
				// best effort
84
				// best effort
86
			}
85
			}
(-)compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java (-107 / +125 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.util;
11
package org.eclipse.jdt.internal.compiler.util;
12
12
13
import java.io.BufferedReader;
13
import java.io.IOException;
14
import java.io.IOException;
14
import java.io.Reader;
15
import java.io.InputStream;
16
import java.io.InputStreamReader;
17
import java.nio.charset.Charset;
15
import java.util.ArrayList;
18
import java.util.ArrayList;
16
import java.util.List;
19
import java.util.List;
17
20
Lines 28-143 Link Here
28
		"Class-Path:".toCharArray(); //$NON-NLS-1$
31
		"Class-Path:".toCharArray(); //$NON-NLS-1$
29
	private int classpathSectionsCount;
32
	private int classpathSectionsCount;
30
	private ArrayList calledFilesNames;
33
	private ArrayList calledFilesNames;
31
	public boolean analyzeManifestContents(Reader reader) throws IOException {
34
	
32
		int state = START, substate = 0;
35
	/**
33
		StringBuffer currentJarToken = new StringBuffer();
36
	 * Analyze the manifest contents. The given input stream is read using a UTF-8 encoded reader.
34
		int currentChar;
37
	 * If the contents of the input stream is not encoded using a UTF-8 encoding, the analysis will fail.
35
		this.classpathSectionsCount = 0;
38
	 * 
36
		this.calledFilesNames = null;
39
	 * @param inputStream the given input stream.
37
		for (;;) {
40
	 * 
38
			currentChar = reader.read();
41
	 * @return <code>true</code> if the analysis is successful, <code>false</code> otherwise.
39
			if (currentChar == '\r')  // skip \r, will consider \n later (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 )
42
	 * @throws IOException if an exception occurs while analyzing the file
43
	 */
44
	public boolean analyzeManifestContents(InputStream inputStream) throws IOException {
45
		BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(Util.UTF_8)));
46
		try {
47
			int state = START, substate = 0;
48
			StringBuffer currentJarToken = new StringBuffer();
49
			int currentChar;
50
			this.classpathSectionsCount = 0;
51
			this.calledFilesNames = null;
52
			for (;;) {
40
				currentChar = reader.read();
53
				currentChar = reader.read();
41
			switch (state) {
54
				if (currentChar == '\r')  // skip \r, will consider \n later (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 )
42
				case START:
55
					currentChar = reader.read();
43
					if (currentChar == -1) {
56
				switch (state) {
44
						return true;
57
					case START:
45
					} else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
58
						if (currentChar == -1) {
46
						state = IN_CLASSPATH_HEADER;
59
							return true;
47
						substate = 1;
60
						} else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
48
					} else {
61
							state = IN_CLASSPATH_HEADER;
49
						state = SKIP_LINE;
62
							substate = 1;
50
					}
63
						} else {
51
					break;
64
							state = SKIP_LINE;
52
				case IN_CLASSPATH_HEADER:
65
						}
53
					if (currentChar == -1) {
66
						break;
54
						return true;
67
					case IN_CLASSPATH_HEADER:
55
					} else if (currentChar == '\n') {
68
						if (currentChar == -1) {
56
						state = START;
69
							return true;
57
					} else if (currentChar != CLASSPATH_HEADER_TOKEN[substate++]) {
70
						} else if (currentChar == '\n') {
58
						state = SKIP_LINE;
71
							state = START;
59
					} else if (substate == CLASSPATH_HEADER_TOKEN.length) {
72
						} else if (currentChar != CLASSPATH_HEADER_TOKEN[substate++]) {
60
						state = PAST_CLASSPATH_HEADER;
73
							state = SKIP_LINE;
61
					}
74
						} else if (substate == CLASSPATH_HEADER_TOKEN.length) {
62
					break;
75
							state = PAST_CLASSPATH_HEADER;
63
				case PAST_CLASSPATH_HEADER:
76
						}
64
					if (currentChar == ' ') {
77
						break;
65
						state = SKIPPING_WHITESPACE;
78
					case PAST_CLASSPATH_HEADER:
66
						this.classpathSectionsCount++;
79
						if (currentChar == ' ') {
67
					} else {
80
							state = SKIPPING_WHITESPACE;
68
						return false;
81
							this.classpathSectionsCount++;
69
					}
82
						} else {
70
					break;
83
							return false;
71
				case SKIPPING_WHITESPACE:
84
						}
72
					if (currentChar == -1) {
85
						break;
73
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
86
					case SKIPPING_WHITESPACE:
74
						addCurrentTokenJarWhenNecessary(currentJarToken);
87
						if (currentChar == -1) {
75
						return true;
88
							// >>>>>>>>>>>>>>>>>> Add the latest jar read
76
					} else if (currentChar == '\n') {
89
							addCurrentTokenJarWhenNecessary(currentJarToken);
77
						state = CONTINUING;
90
							return true;
78
					} else if (currentChar != ' ') {
91
						} else if (currentChar == '\n') {
79
						currentJarToken.append((char) currentChar);
92
							state = CONTINUING;
80
						state = READING_JAR;
93
						} else if (currentChar != ' ') {
81
					} else {
94
							currentJarToken.append((char) currentChar);
82
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
95
							state = READING_JAR;
83
						addCurrentTokenJarWhenNecessary(currentJarToken);
96
						} else {
84
					}
97
							// >>>>>>>>>>>>>>>>>> Add the latest jar read
85
					break;
98
							addCurrentTokenJarWhenNecessary(currentJarToken);
86
				case CONTINUING:
99
						}
87
					if (currentChar == -1) {
100
						break;
88
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
101
					case CONTINUING:
89
						addCurrentTokenJarWhenNecessary(currentJarToken);
102
						if (currentChar == -1) {
90
						return true;
103
							// >>>>>>>>>>>>>>>>>> Add the latest jar read
91
					} else if (currentChar == '\n') {
104
							addCurrentTokenJarWhenNecessary(currentJarToken);
92
						addCurrentTokenJarWhenNecessary(currentJarToken);
105
							return true;
93
						state = START;
106
						} else if (currentChar == '\n') {
94
					} else if (currentChar == ' ') {
107
							addCurrentTokenJarWhenNecessary(currentJarToken);
95
						state = SKIPPING_WHITESPACE;
108
							state = START;
96
					} else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
109
						} else if (currentChar == ' ') {
97
						addCurrentTokenJarWhenNecessary(currentJarToken);
110
							state = SKIPPING_WHITESPACE;
98
						state = IN_CLASSPATH_HEADER;
111
						} else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
99
						substate = 1;
112
							addCurrentTokenJarWhenNecessary(currentJarToken);
100
					} else if (this.calledFilesNames == null) {
113
							state = IN_CLASSPATH_HEADER;
101
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
114
							substate = 1;
102
						addCurrentTokenJarWhenNecessary(currentJarToken);
115
						} else if (this.calledFilesNames == null) {
103
						state = START;
116
							// >>>>>>>>>>>>>>>>>> Add the latest jar read
104
					} else {
117
							addCurrentTokenJarWhenNecessary(currentJarToken);
105
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
118
							state = START;
106
						addCurrentTokenJarWhenNecessary(currentJarToken);
119
						} else {
107
						state = SKIP_LINE;
120
							// >>>>>>>>>>>>>>>>>> Add the latest jar read
108
					}
121
							addCurrentTokenJarWhenNecessary(currentJarToken);
109
					break;
122
							state = SKIP_LINE;
110
				case SKIP_LINE:
123
						}
111
					if (currentChar == -1) {
124
						break;
112
						if (this.classpathSectionsCount != 0) {
125
					case SKIP_LINE:
113
							if (this.calledFilesNames == null) {
126
						if (currentChar == -1) {
114
								return false;
127
							if (this.classpathSectionsCount != 0) {
128
								if (this.calledFilesNames == null) {
129
									return false;
130
								}
115
							}
131
							}
132
							return true;
133
						} else if (currentChar == '\n') {
134
							state = START;
135
						}
136
						break;
137
					case READING_JAR:
138
						if (currentChar == -1) {
139
							// >>>>>>>>>>>>>>>>>> Add the latest jar read
140
							return false;
141
						} else if (currentChar == '\n') {
142
							// appends token below
143
							state = CONTINUING;
144
							// >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line
145
							break;
146
						} else if (currentChar == ' ') {
147
							// appends token below
148
							state = SKIPPING_WHITESPACE;
149
						} else {
150
							currentJarToken.append((char) currentChar);
151
							break;
116
						}
152
						}
117
						return true;
153
						addCurrentTokenJarWhenNecessary(currentJarToken);
118
					} else if (currentChar == '\n') {
154
						break;
119
						state = START;
155
				}
120
					}
121
					break;
122
				case READING_JAR:
123
					if (currentChar == -1) {
124
						// >>>>>>>>>>>>>>>>>> Add the latest jar read
125
						return false;
126
					} else if (currentChar == '\n') {
127
						// appends token below
128
						state = CONTINUING;
129
						// >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line
130
						break;
131
					} else if (currentChar == ' ') {
132
						// appends token below
133
						state = SKIPPING_WHITESPACE;
134
					} else {
135
						currentJarToken.append((char) currentChar);
136
						break;
137
					}
138
					addCurrentTokenJarWhenNecessary(currentJarToken);
139
					break;
140
			}
156
			}
157
		} finally {
158
			reader.close();
141
		}
159
		}
142
	}	
160
	}	
143
161
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java (-27 / +32 lines)
Lines 10-17 Link Here
10
 *     IBM Corporation - code review and integration
10
 *     IBM Corporation - code review and integration
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
13
import java.io.ByteArrayInputStream;
13
import java.io.IOException;
14
import java.io.IOException;
14
import java.io.StringReader;
15
import java.io.InputStream;
15
import java.util.List;
16
import java.util.List;
16
17
17
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
18
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
Lines 29-45 Link Here
29
	}
30
	}
30
	public void testWithOneJar() throws IOException {
31
	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
		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
		analyzeManifestContents(testWithOneJar);
33
		this.manifestAnalyzer.analyzeManifestContents(reader);
34
		List jars = this.manifestAnalyzer.getCalledFileNames();
34
		List jars = this.manifestAnalyzer.getCalledFileNames();
35
		assertEquals("Wrong size", 1, jars.size());
35
		assertEquals("Wrong size", 1, jars.size());
36
		assertEquals(FIRST_JAR, jars.get(0));
36
		assertEquals(FIRST_JAR, jars.get(0));
37
	}
37
	}
38
38
39
	private void analyzeManifestContents(String contents) throws IOException {
40
		InputStream stream = new ByteArrayInputStream(contents.getBytes());
41
		try {
42
			this.manifestAnalyzer.analyzeManifestContents(stream);
43
		} catch(IOException e) {
44
			stream.close();
45
		}
46
	}
39
	public void testWithOneJarWithWiteSpace() throws IOException {
47
	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";
48
		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);
49
		analyzeManifestContents(testWithOneJarWithWiteSpace);
42
		this.manifestAnalyzer.analyzeManifestContents(reader);
43
		List jars = this.manifestAnalyzer.getCalledFileNames();
50
		List jars = this.manifestAnalyzer.getCalledFileNames();
44
		assertEquals("Wrong size", 1, jars.size());
51
		assertEquals("Wrong size", 1, jars.size());
45
		assertEquals(FIRST_JAR, jars.get(0));
52
		assertEquals(FIRST_JAR, jars.get(0));
Lines 47-54 Link Here
47
54
48
	public void testWithSecondJarOnNextLine() throws IOException {
55
	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";
56
		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);
57
		analyzeManifestContents(testWithSecondJarOnNextLine);
51
		this.manifestAnalyzer.analyzeManifestContents(reader);
52
		List jars = this.manifestAnalyzer.getCalledFileNames();
58
		List jars = this.manifestAnalyzer.getCalledFileNames();
53
		assertEquals("Wrong size", 2, jars.size());
59
		assertEquals("Wrong size", 2, jars.size());
54
		assertEquals(FIRST_JAR, jars.get(0));
60
		assertEquals(FIRST_JAR, jars.get(0));
Lines 57-64 Link Here
57
63
58
	public void testWithSecondJarOnTwoLine() throws IOException {
64
	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 + WHITESPACE + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
65
		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 + WHITESPACE + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
60
		StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
66
		analyzeManifestContents(testWithSecondJarOnTwoLine);
61
		this.manifestAnalyzer.analyzeManifestContents(reader);
62
		List jars = this.manifestAnalyzer.getCalledFileNames();
67
		List jars = this.manifestAnalyzer.getCalledFileNames();
63
		assertEquals("Wrong size", 2, jars.size());
68
		assertEquals("Wrong size", 2, jars.size());
64
		assertEquals(FIRST_JAR, jars.get(0));
69
		assertEquals(FIRST_JAR, jars.get(0));
Lines 67-74 Link Here
67
72
68
	public void testWithSecondJarOnTwoLine2() throws IOException {
73
	public void testWithSecondJarOnTwoLine2() throws IOException {
69
		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 + WHITESPACE + "second\n" + WHITESPACE + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
74
		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 + WHITESPACE + "second\n" + WHITESPACE + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
70
		StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
75
		analyzeManifestContents(testWithSecondJarOnTwoLine);
71
		this.manifestAnalyzer.analyzeManifestContents(reader);
72
		List jars = this.manifestAnalyzer.getCalledFileNames();
76
		List jars = this.manifestAnalyzer.getCalledFileNames();
73
		assertEquals("Wrong size", 3, jars.size());
77
		assertEquals("Wrong size", 3, jars.size());
74
		assertEquals(FIRST_JAR, jars.get(0));
78
		assertEquals(FIRST_JAR, jars.get(0));
Lines 78-85 Link Here
78
82
79
	public void testWithSecondJarOnTwoLine3() throws IOException {
83
	public void testWithSecondJarOnTwoLine3() throws IOException {
80
		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 + WHITESPACE + "second\n" + "Jar.jar\nBuild-Reference: Version toto";
84
		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 + WHITESPACE + "second\n" + "Jar.jar\nBuild-Reference: Version toto";
81
		StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
85
		analyzeManifestContents(testWithSecondJarOnTwoLine);
82
		this.manifestAnalyzer.analyzeManifestContents(reader);
83
		List jars = this.manifestAnalyzer.getCalledFileNames();
86
		List jars = this.manifestAnalyzer.getCalledFileNames();
84
		assertEquals("Wrong size", 2, jars.size());
87
		assertEquals("Wrong size", 2, jars.size());
85
		assertEquals(FIRST_JAR, jars.get(0));
88
		assertEquals(FIRST_JAR, jars.get(0));
Lines 88-95 Link Here
88
91
89
	public void testWithSecondJarOnTwoLine4() throws IOException {
92
	public void testWithSecondJarOnTwoLine4() throws IOException {
90
		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 + "\n" + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
93
		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 + "\n" + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto";
91
		StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
94
		analyzeManifestContents(testWithSecondJarOnTwoLine);
92
		this.manifestAnalyzer.analyzeManifestContents(reader);
93
		List jars = this.manifestAnalyzer.getCalledFileNames();
95
		List jars = this.manifestAnalyzer.getCalledFileNames();
94
		assertEquals("Wrong size", 1, jars.size());
96
		assertEquals("Wrong size", 1, jars.size());
95
		assertEquals(FIRST_JAR, jars.get(0));
97
		assertEquals(FIRST_JAR, jars.get(0));
Lines 97-104 Link Here
97
99
98
	public void testWithSecondJarOnNextLine5() throws IOException {
100
	public void testWithSecondJarOnNextLine5() throws IOException {
99
		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 + "secondJar.jar\nBuild-Reference: Version toto";
101
		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 + "secondJar.jar\nBuild-Reference: Version toto";
100
		StringReader reader = new StringReader(testWithSecondJarOnNextLine);
102
		analyzeManifestContents(testWithSecondJarOnNextLine);
101
		this.manifestAnalyzer.analyzeManifestContents(reader);
102
		List jars = this.manifestAnalyzer.getCalledFileNames();
103
		List jars = this.manifestAnalyzer.getCalledFileNames();
103
		assertEquals("Wrong size", 1, jars.size());
104
		assertEquals("Wrong size", 1, jars.size());
104
		assertEquals(FIRST_JAR + SECOND_JAR, jars.get(0));
105
		assertEquals(FIRST_JAR + SECOND_JAR, jars.get(0));
Lines 106-113 Link Here
106
107
107
	public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException {
108
	public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException {
108
		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";
109
		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";
109
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF);
110
		analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF);
110
		this.manifestAnalyzer.analyzeManifestContents(reader);
111
		List jars = this.manifestAnalyzer.getCalledFileNames();
111
		List jars = this.manifestAnalyzer.getCalledFileNames();
112
		assertEquals("Wrong size", 1, jars.size());
112
		assertEquals("Wrong size", 1, jars.size());
113
		assertEquals(FIRST_JAR, jars.get(0));
113
		assertEquals(FIRST_JAR, jars.get(0));
Lines 115-122 Link Here
115
115
116
	public void testWithSecondJarOnTwoLineEndedWithEOF2() throws IOException {
116
	public void testWithSecondJarOnTwoLineEndedWithEOF2() throws IOException {
117
		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\n";
117
		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\n";
118
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF);
118
		analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF);
119
		this.manifestAnalyzer.analyzeManifestContents(reader);
120
		List jars = this.manifestAnalyzer.getCalledFileNames();
119
		List jars = this.manifestAnalyzer.getCalledFileNames();
121
		assertEquals("Wrong size", 2, jars.size());
120
		assertEquals("Wrong size", 2, jars.size());
122
		assertEquals(FIRST_JAR, jars.get(0));
121
		assertEquals(FIRST_JAR, jars.get(0));
Lines 125-132 Link Here
125
124
126
	public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException {
125
	public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException {
127
		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 ";
126
		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 ";
128
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF);
127
		analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF);
129
		this.manifestAnalyzer.analyzeManifestContents(reader);
130
		List jars = this.manifestAnalyzer.getCalledFileNames();
128
		List jars = this.manifestAnalyzer.getCalledFileNames();
131
		assertEquals("Wrong size", 2, jars.size());
129
		assertEquals("Wrong size", 2, jars.size());
132
		assertEquals(FIRST_JAR, jars.get(0));
130
		assertEquals(FIRST_JAR, jars.get(0));
Lines 135-142 Link Here
135
133
136
	public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException {
134
	public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException {
137
		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";
135
		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";
138
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF);
136
		analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF);
139
		this.manifestAnalyzer.analyzeManifestContents(reader);
140
		List jars = this.manifestAnalyzer.getCalledFileNames();
137
		List jars = this.manifestAnalyzer.getCalledFileNames();
141
		assertEquals("Wrong size", 2, jars.size());
138
		assertEquals("Wrong size", 2, jars.size());
142
		assertEquals(FIRST_JAR, jars.get(0));
139
		assertEquals(FIRST_JAR, jars.get(0));
Lines 145-155 Link Here
145
142
146
	public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException {
143
	public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException {
147
		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";
144
		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";
148
		StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithNewLineEOF);
145
		analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithNewLineEOF);
149
		this.manifestAnalyzer.analyzeManifestContents(reader);
150
		List jars = this.manifestAnalyzer.getCalledFileNames();
146
		List jars = this.manifestAnalyzer.getCalledFileNames();
151
		assertEquals("Wrong size", 2, jars.size());
147
		assertEquals("Wrong size", 2, jars.size());
152
		assertEquals(FIRST_JAR, jars.get(0));
148
		assertEquals(FIRST_JAR, jars.get(0));
153
		assertEquals(SECOND_JAR, jars.get(1));
149
		assertEquals(SECOND_JAR, jars.get(1));
154
	}
150
	}
151
152
	public void testWithOneJarUsingUTF8Name() throws IOException {
153
		InputStream inputStream = ManifestAnalyzerTest.class.getResourceAsStream("MANIFEST.MF");
154
		this.manifestAnalyzer.analyzeManifestContents(inputStream);
155
		inputStream.close();
156
		List jars = this.manifestAnalyzer.getCalledFileNames();
157
		assertEquals("Wrong size", 1, jars.size());
158
		assertEquals("called\u3042.jar", jars.get(0));
159
	}
155
}
160
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-62 / +73 lines)
Lines 12-21 Link Here
12
package org.eclipse.jdt.core.tests.compiler.regression;
12
package org.eclipse.jdt.core.tests.compiler.regression;
13
13
14
import java.io.BufferedReader;
14
import java.io.BufferedReader;
15
import java.io.ByteArrayInputStream;
15
import java.io.File;
16
import java.io.File;
16
import java.io.FileNotFoundException;
17
import java.io.FileNotFoundException;
17
import java.io.FileOutputStream;
18
import java.io.FileOutputStream;
18
import java.io.IOException;
19
import java.io.IOException;
20
import java.io.InputStream;
19
import java.io.PrintWriter;
21
import java.io.PrintWriter;
20
import java.io.StringReader;
22
import java.io.StringReader;
21
import java.text.MessageFormat;
23
import java.text.MessageFormat;
Lines 10518-10530 Link Here
10518
public void test268_jar_ref_in_jar(){
10520
public void test268_jar_ref_in_jar(){
10519
	try {
10521
	try {
10520
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10522
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10521
		assertTrue(analyzer.analyzeManifestContents(
10523
		assertTrue(analyzeManifestContents(
10522
			new StringReader(
10524
			analyzer,
10523
				"Manifest-Version: 1.0\n" +
10525
			"Manifest-Version: 1.0\n" +
10524
				"Created-By: Eclipse JDT Test Harness\n" +
10526
			"Created-By: Eclipse JDT Test Harness\n" +
10525
				"Class-Path: lib1.jar\n" +
10527
			"Class-Path: lib1.jar\n" +
10526
				"\n" +
10528
			"\n" +
10527
				"Class-Path: lib3.jar\n")));
10529
			"Class-Path: lib3.jar\n"));
10528
		assertEquals(2, analyzer.getClasspathSectionsCount());
10530
		assertEquals(2, analyzer.getClasspathSectionsCount());
10529
		assertEquals(2, analyzer.getCalledFileNames().size());
10531
		assertEquals(2, analyzer.getCalledFileNames().size());
10530
	} catch (IOException e) {
10532
	} catch (IOException e) {
Lines 10539-10551 Link Here
10539
public void test269_jar_ref_in_jar(){
10541
public void test269_jar_ref_in_jar(){
10540
	try {
10542
	try {
10541
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10543
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10542
		assertTrue(analyzer.analyzeManifestContents(
10544
		assertTrue(analyzeManifestContents(
10543
			new StringReader(
10545
			analyzer,
10544
				"Manifest-Version: 1.0\n" +
10546
			"Manifest-Version: 1.0\n" +
10545
				"Created-By: Eclipse JDT Test Harness\n" +
10547
			"Created-By: Eclipse JDT Test Harness\n" +
10546
				"Class-Path: lib1.jar\n" +
10548
			"Class-Path: lib1.jar\n" +
10547
				"Dummy:\n" +
10549
			"Dummy:\n" +
10548
				"Class-Path: lib3.jar\n")));
10550
			"Class-Path: lib3.jar\n"));
10549
		assertEquals(2, analyzer.getClasspathSectionsCount());
10551
		assertEquals(2, analyzer.getClasspathSectionsCount());
10550
		assertEquals(2, analyzer.getCalledFileNames().size());
10552
		assertEquals(2, analyzer.getCalledFileNames().size());
10551
	} catch (IOException e) {
10553
	} catch (IOException e) {
Lines 10559-10569 Link Here
10559
public void test270_jar_ref_in_jar(){
10561
public void test270_jar_ref_in_jar(){
10560
	try {
10562
	try {
10561
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10563
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10562
		assertTrue(analyzer.analyzeManifestContents(
10564
		assertTrue(analyzeManifestContents(
10563
			new StringReader(
10565
			analyzer,
10564
				"Manifest-Version: 1.0\n" +
10566
			"Manifest-Version: 1.0\n" +
10565
				"Created-By: Eclipse JDT Test Harness\n" +
10567
			"Created-By: Eclipse JDT Test Harness\n" +
10566
				"Class-Path: lib1.jar\tlib2.jar\n")));
10568
			"Class-Path: lib1.jar\tlib2.jar\n"));
10567
		assertEquals(1, analyzer.getClasspathSectionsCount());
10569
		assertEquals(1, analyzer.getClasspathSectionsCount());
10568
		assertEquals(1, analyzer.getCalledFileNames().size());
10570
		assertEquals(1, analyzer.getCalledFileNames().size());
10569
	} catch (IOException e) {
10571
	} catch (IOException e) {
Lines 10600-10612 Link Here
10600
public void test272_jar_ref_in_jar(){
10602
public void test272_jar_ref_in_jar(){
10601
	try {
10603
	try {
10602
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10604
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10603
		assertTrue(analyzer.analyzeManifestContents(
10605
		assertTrue(analyzeManifestContents(
10604
			new StringReader(
10606
			analyzer,
10605
				"Manifest-Version: 1.0\n" +
10607
			"Manifest-Version: 1.0\n" +
10606
				"Created-By: Eclipse JDT Test Harness\n" +
10608
			"Created-By: Eclipse JDT Test Harness\n" +
10607
				"Class-Path: \n" +
10609
			"Class-Path: \n" +
10608
				"            lib1.jar       \n" +
10610
			"            lib1.jar       \n" +
10609
				"\n")));
10611
			"\n"));
10610
		assertEquals(1, analyzer.getClasspathSectionsCount());
10612
		assertEquals(1, analyzer.getClasspathSectionsCount());
10611
		assertEquals(1, analyzer.getCalledFileNames().size());
10613
		assertEquals(1, analyzer.getCalledFileNames().size());
10612
	} catch (IOException e) {
10614
	} catch (IOException e) {
Lines 10619-10634 Link Here
10619
public void test273_jar_ref_in_jar(){
10621
public void test273_jar_ref_in_jar(){
10620
	try {
10622
	try {
10621
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10623
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10622
		assertTrue(analyzer.analyzeManifestContents(
10624
		assertTrue(analyzeManifestContents(
10623
			new StringReader(
10625
			analyzer,
10624
				"Manifest-Version: 1.0\n" +
10626
			"Manifest-Version: 1.0\n" +
10625
				"Created-By: Eclipse JDT Test Harness\n" +
10627
			"Created-By: Eclipse JDT Test Harness\n" +
10626
				"Class-Path: \n" +
10628
			"Class-Path: \n" +
10627
				" \n" +
10629
			" \n" +
10628
				"            lib1.jar       \n" +
10630
			"            lib1.jar       \n" +
10629
				" \n" +
10631
			" \n" +
10630
				"            lib1.jar       \n" +
10632
			"            lib1.jar       \n" +
10631
				"\n")));
10633
			"\n"));
10632
		assertEquals(1, analyzer.getClasspathSectionsCount());
10634
		assertEquals(1, analyzer.getClasspathSectionsCount());
10633
		assertEquals(2, analyzer.getCalledFileNames().size());
10635
		assertEquals(2, analyzer.getCalledFileNames().size());
10634
	} catch (IOException e) {
10636
	} catch (IOException e) {
Lines 10641-10652 Link Here
10641
public void test274_jar_ref_in_jar(){
10643
public void test274_jar_ref_in_jar(){
10642
	try {
10644
	try {
10643
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10645
		ManifestAnalyzer analyzer = new ManifestAnalyzer();
10644
		assertFalse(analyzer.analyzeManifestContents(
10646
		assertFalse(analyzeManifestContents(
10645
			new StringReader(
10647
			analyzer,
10646
				"Manifest-Version: 1.0\n" +
10648
			"Manifest-Version: 1.0\n" +
10647
				"Created-By: Eclipse JDT Test Harness\n" +
10649
			"Created-By: Eclipse JDT Test Harness\n" +
10648
				"Class-Path: \n" +
10650
			"Class-Path: \n" +
10649
				"            lib1.jar")));
10651
			"            lib1.jar"));
10650
	} catch (IOException e) {
10652
	} catch (IOException e) {
10651
		e.printStackTrace();
10653
		e.printStackTrace();
10652
		fail();
10654
		fail();
Lines 10656-10683 Link Here
10656
// white-box test: variants on continuations
10658
// white-box test: variants on continuations
10657
public void test275_jar_ref_in_jar(){
10659
public void test275_jar_ref_in_jar(){
10658
	try {
10660
	try {
10659
		assertFalse(new ManifestAnalyzer().analyzeManifestContents(
10661
		assertFalse(analyzeManifestContents(
10660
			new StringReader(
10662
			new ManifestAnalyzer(),
10661
				"Manifest-Version: 1.0\n" +
10663
			"Manifest-Version: 1.0\n" +
10662
				"Created-By: Eclipse JDT Test Harness\n" +
10664
			"Created-By: Eclipse JDT Test Harness\n" +
10663
				"Class-Path: \n" +
10665
			"Class-Path: \n" +
10664
				" \n" +
10666
			" \n" +
10665
				"            lib1.jar")));
10667
			"            lib1.jar"));
10666
	} catch (IOException e) {
10668
	} catch (IOException e) {
10667
		e.printStackTrace();
10669
		e.printStackTrace();
10668
		fail();
10670
		fail();
10669
	}
10671
	}
10670
}
10672
}
10673
private boolean analyzeManifestContents(ManifestAnalyzer manifestAnalyzer,
10674
		String string) throws IOException {
10675
	InputStream stream = new ByteArrayInputStream(string.getBytes());
10676
	try {
10677
		return manifestAnalyzer.analyzeManifestContents(stream);
10678
	} finally {
10679
		stream.close();
10680
	}
10681
}
10671
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
10682
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
10672
// white-box test: variants on continuations
10683
// white-box test: variants on continuations
10673
public void test276_jar_ref_in_jar(){
10684
public void test276_jar_ref_in_jar(){
10674
	try {
10685
	try {
10675
		assertFalse(new ManifestAnalyzer().analyzeManifestContents(
10686
		assertFalse(analyzeManifestContents(
10676
			new StringReader(
10687
			new ManifestAnalyzer(),
10677
				"Manifest-Version: 1.0\n" +
10688
			"Manifest-Version: 1.0\n" +
10678
				"Created-By: Eclipse JDT Test Harness\n" +
10689
			"Created-By: Eclipse JDT Test Harness\n" +
10679
				"Class-Path:      \n" +
10690
			"Class-Path:      \n" +
10680
				"lib1.jar")));
10691
			"lib1.jar"));
10681
	} catch (IOException e) {
10692
	} catch (IOException e) {
10682
		e.printStackTrace();
10693
		e.printStackTrace();
10683
		fail();
10694
		fail();
Lines 11031-11043 Link Here
11031
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 
11042
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 
11032
public void test291_jar_ref_in_jar() throws Exception {
11043
public void test291_jar_ref_in_jar() throws Exception {
11033
	ManifestAnalyzer analyzer = new ManifestAnalyzer();
11044
	ManifestAnalyzer analyzer = new ManifestAnalyzer();
11034
	assertTrue(analyzer.analyzeManifestContents(
11045
	assertTrue(analyzeManifestContents(
11035
		new StringReader(
11046
		analyzer,
11036
			"Manifest-Version: 1.0\r\n" +
11047
		"Manifest-Version: 1.0\r\n" +
11037
			"Created-By: Eclipse JDT Test Harness\r\n" +
11048
		"Created-By: Eclipse JDT Test Harness\r\n" +
11038
			"Class-Path: \r\n" +
11049
		"Class-Path: \r\n" +
11039
			"\r\n"
11050
		"\r\n"
11040
		)));
11051
		));
11041
	List calledFileNames = analyzer.getCalledFileNames();
11052
	List calledFileNames = analyzer.getCalledFileNames();
11042
	String actual = calledFileNames == null ? "<null>" : Util.toString((String[]) calledFileNames.toArray(new String[calledFileNames.size()]), false/*don't add extra new lines*/);
11053
	String actual = calledFileNames == null ? "<null>" : Util.toString((String[]) calledFileNames.toArray(new String[calledFileNames.size()]), false/*don't add extra new lines*/);
11043
	assertStringEquals(
11054
	assertStringEquals(
(-)src/org/eclipse/jdt/core/tests/compiler/regression/MANIFEST.MF (+4 lines)
Added Link Here
1
Manifest-Version: 1.0
2
Class-Path: calledã?‚.jar
3
Created-By: 1.6.0 (IBM Corporation)
4

Return to bug 272450