Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 132292 Details for
Bug 272450
DBCS3.5: Classpath resolution fails to honor the 'Class-Path' header of JAR manifest file in DBCS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_272450.txt (text/plain), 39.16 KB, created by
Olivier Thomann
on 2009-04-17 16:07:17 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2009-04-17 16:07:17 EDT
Size:
39.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v >retrieving revision 1.115 >diff -u -r1.115 ClasspathEntry.java >--- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 7 Mar 2009 00:58:57 -0000 1.115 >+++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 17 Apr 2009 20:05:50 -0000 >@@ -10,11 +10,10 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.core; > >-import java.io.BufferedReader; > import java.io.ByteArrayOutputStream; > import java.io.File; > import java.io.IOException; >-import java.io.InputStreamReader; >+import java.io.InputStream; > import java.io.OutputStreamWriter; > import java.io.UnsupportedEncodingException; > import java.util.ArrayList; >@@ -49,8 +48,8 @@ > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.internal.compiler.env.AccessRestriction; >-import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; > import org.eclipse.jdt.internal.compiler.env.AccessRule; >+import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer; > import org.eclipse.jdt.internal.core.util.Messages; >@@ -904,7 +903,7 @@ > return null; > JavaModelManager manager = JavaModelManager.getJavaModelManager(); > ZipFile zip = null; >- BufferedReader reader = null; >+ InputStream inputStream = null; > List calledFileNames = null; > try { > zip = manager.getZipFile(jarPath); >@@ -912,9 +911,9 @@ > if (manifest == null) > return null; > // non-null implies regular file >- reader = new BufferedReader(new InputStreamReader(zip.getInputStream(manifest))); > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- boolean success = analyzer.analyzeManifestContents(reader); >+ inputStream = zip.getInputStream(manifest); >+ boolean success = analyzer.analyzeManifestContents(inputStream); > calledFileNames = analyzer.getCalledFileNames(); > if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) { > if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { >@@ -941,9 +940,9 @@ > } > } finally { > manager.closeZipFile(zip); >- if (reader != null) { >+ if (inputStream != null) { > try { >- reader.close(); >+ inputStream.close(); > } catch (IOException e) { > // best effort > } >@@ -1462,7 +1461,7 @@ > * <li> The project output location path cannot be null, must be absolute and located inside the project. > * <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project, > * <li> A project entry cannot refer to itself directly (that is, a project cannot prerequisite itself). >- * <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below: >+ * <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below: > * <ul><li> A source folder can coincidate with its own output location, in which case this output can then contain library archives. > * However, a specific output location cannot coincidate with any library or a distinct source folder than the one referring to it. </li> > * <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> >@@ -1581,8 +1580,8 @@ > } > // check nesting across output locations > for (int i = 1 /*no check for default output*/ ; i < outputCount; i++) { >- IPath customOutput = outputLocations[i]; >- int index; >+ IPath customOutput = outputLocations[i]; >+ int index; > // check nesting > if ((index = Util.indexOfEnclosingPath(customOutput, outputLocations, outputCount)) != -1 && index != i) { > if (index == 0) { >@@ -1681,26 +1680,26 @@ > } > > // prevent nesting output location inside entry unless enclosing is a source entry which explicitly exclude the output location >- char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars(); >- char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars(); >- for (int j = 0; j < outputCount; j++){ >- IPath currentOutput = outputLocations[j]; >- if (entryPath.equals(currentOutput)) continue; >+ char[][] inclusionPatterns = ((ClasspathEntry)entry).fullInclusionPatternChars(); >+ char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars(); >+ for (int j = 0; j < outputCount; j++){ >+ IPath currentOutput = outputLocations[j]; >+ if (entryPath.equals(currentOutput)) continue; > if (entryPath.isPrefixOf(currentOutput)) { > if (kind != IClasspathEntry.CPE_SOURCE || !Util.isExcluded(currentOutput, inclusionPatterns, exclusionPatterns, true)) { > return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestOutputInEntry, new String[] {currentOutput.makeRelative().toString(), entryPath.makeRelative().toString()})); > } > } >- } >+ } > >- // prevent nesting entry inside output location - when distinct from project or a source folder >- for (int j = 0; j < outputCount; j++){ >- if (allowNestingInOutputLocations[j]) continue; >- IPath currentOutput = outputLocations[j]; >+ // prevent nesting entry inside output location - when distinct from project or a source folder >+ for (int j = 0; j < outputCount; j++){ >+ if (allowNestingInOutputLocations[j]) continue; >+ IPath currentOutput = outputLocations[j]; > if (currentOutput.isPrefixOf(entryPath)) { > return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_cannotNestEntryInOutput, new String[] {entryPath.makeRelative().toString(), currentOutput.makeRelative().toString()})); > } >- } >+ } > } > // ensure that no specific output is coincidating with another source folder (only allowed if matching current source folder) > // 36465 - for 2.0 backward compatibility, only check specific output locations (the default can still coincidate) >@@ -1921,7 +1920,7 @@ > // project source folder > case IClasspathEntry.CPE_SOURCE : > if (((entry.getInclusionPatterns() != null && entry.getInclusionPatterns().length > 0) >- || (entry.getExclusionPatterns() != null && entry.getExclusionPatterns().length > 0)) >+ || (entry.getExclusionPatterns() != null && entry.getExclusionPatterns().length > 0)) > && JavaCore.DISABLED.equals(project.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) { > return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, project, path); > } >@@ -2014,21 +2013,21 @@ > } > } else if (target instanceof File){ > File file = JavaModel.getFile(target); >- if (file == null) { >- if (container != null) { >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container})); >- } else { >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()})); >- } >- } else if (sourceAttachment != null >+ if (file == null) { >+ if (container != null) { >+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolderInContainer, new String[] {path.toOSString(), container})); >+ } else { >+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_illegalExternalFolder, new String[] {path.toOSString(), project.getElementName()})); >+ } >+ } else if (sourceAttachment != null > && !sourceAttachment.isEmpty() > && JavaModel.getTarget(sourceAttachment, true) == null){ >- if (container != null) { >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container})); >- } else { >- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()})); >- } >- } >+ if (container != null) { >+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachmentInContainedLibrary, new String [] {sourceAttachment.toString(), path.toOSString(), container})); >+ } else { >+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Messages.bind(Messages.classpath_unboundSourceAttachment, new String [] {sourceAttachment.toString(), path.toOSString(), project.getElementName()})); >+ } >+ } > } else { > boolean isExternal = path.getDevice() != null || !ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)).exists(); > if (isExternal) { >Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java,v >retrieving revision 1.50 >diff -u -r1.50 ClasspathJar.java >--- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 7 Mar 2009 00:59:05 -0000 1.50 >+++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 17 Apr 2009 20:05:50 -0000 >@@ -10,10 +10,9 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.batch; > >-import java.io.BufferedReader; > import java.io.File; > import java.io.IOException; >-import java.io.InputStreamReader; >+import java.io.InputStream; > import java.util.ArrayList; > import java.util.Enumeration; > import java.util.Hashtable; >@@ -47,15 +46,15 @@ > public List fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) { > // expected to be called once only - if multiple calls desired, consider > // using a cache >- BufferedReader reader = null; >+ InputStream inputStream = null; > try { > initialize(); > ArrayList result = new ArrayList(); > ZipEntry manifest = this.zipFile.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$ > if (manifest != null) { // non-null implies regular file >- reader = new BufferedReader(new InputStreamReader(this.zipFile.getInputStream(manifest))); >+ inputStream = this.zipFile.getInputStream(manifest); > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- boolean success = analyzer.analyzeManifestContents(reader); >+ boolean success = analyzer.analyzeManifestContents(inputStream); > List calledFileNames = analyzer.getCalledFileNames(); > if (problemReporter != null) { > if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) { >@@ -78,9 +77,9 @@ > } catch (IOException e) { > return null; > } finally { >- if (reader != null) { >+ if (inputStream != null) { > try { >- reader.close(); >+ inputStream.close(); > } catch (IOException e) { > // best effort > } >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.3 >diff -u -r1.3 ManifestAnalyzer.java >--- compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java 4 Mar 2009 16:13:46 -0000 1.3 >+++ compiler/org/eclipse/jdt/internal/compiler/util/ManifestAnalyzer.java 17 Apr 2009 20:05:50 -0000 >@@ -10,8 +10,11 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.util; > >+import java.io.BufferedReader; > import java.io.IOException; >-import java.io.Reader; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.nio.charset.Charset; > import java.util.ArrayList; > import java.util.List; > >@@ -28,116 +31,131 @@ > "Class-Path:".toCharArray(); //$NON-NLS-1$ > private int classpathSectionsCount; > private ArrayList calledFilesNames; >- public boolean analyzeManifestContents(Reader reader) throws IOException { >- int state = START, substate = 0; >- StringBuffer currentJarToken = new StringBuffer(); >- int currentChar; >- this.classpathSectionsCount = 0; >- 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 ) >+ >+ /** >+ * Analyze the manifest contents. The given input stream is read using a UTF-8 encoded reader. >+ * If the contents of the input stream is not encoded using a UTF-8 encoding, the analysis will fail. >+ * >+ * @param inputStream the given input stream. >+ * >+ * @return <code>true</code> if the analysis is successful, <code>false</code> otherwise. >+ * @throws IOException if an exception occurs while analyzing the file >+ */ >+ public boolean analyzeManifestContents(InputStream inputStream) throws IOException { >+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(Util.UTF_8))); >+ try { >+ int state = START, substate = 0; >+ StringBuffer currentJarToken = new StringBuffer(); >+ int currentChar; >+ this.classpathSectionsCount = 0; >+ this.calledFilesNames = null; >+ for (;;) { > currentChar = reader.read(); >- switch (state) { >- case START: >- if (currentChar == -1) { >- return true; >- } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) { >- state = IN_CLASSPATH_HEADER; >- substate = 1; >- } else { >- state = SKIP_LINE; >- } >- break; >- case IN_CLASSPATH_HEADER: >- if (currentChar == -1) { >- return true; >- } else if (currentChar == '\n') { >- state = START; >- } else if (currentChar != CLASSPATH_HEADER_TOKEN[substate++]) { >- state = SKIP_LINE; >- } else if (substate == CLASSPATH_HEADER_TOKEN.length) { >- state = PAST_CLASSPATH_HEADER; >- } >- break; >- case PAST_CLASSPATH_HEADER: >- if (currentChar == ' ') { >- state = SKIPPING_WHITESPACE; >- this.classpathSectionsCount++; >- } else { >- return false; >- } >- break; >- case SKIPPING_WHITESPACE: >- if (currentChar == -1) { >- // >>>>>>>>>>>>>>>>>> Add the latest jar read >- addCurrentTokenJarWhenNecessary(currentJarToken); >- return true; >- } else if (currentChar == '\n') { >- state = CONTINUING; >- } else if (currentChar != ' ') { >- currentJarToken.append((char) currentChar); >- state = READING_JAR; >- } else { >- // >>>>>>>>>>>>>>>>>> Add the latest jar read >- addCurrentTokenJarWhenNecessary(currentJarToken); >- } >- break; >- case CONTINUING: >- if (currentChar == -1) { >- // >>>>>>>>>>>>>>>>>> Add the latest jar read >- addCurrentTokenJarWhenNecessary(currentJarToken); >- return true; >- } else if (currentChar == '\n') { >- addCurrentTokenJarWhenNecessary(currentJarToken); >- state = START; >- } else if (currentChar == ' ') { >- state = SKIPPING_WHITESPACE; >- } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) { >- addCurrentTokenJarWhenNecessary(currentJarToken); >- state = IN_CLASSPATH_HEADER; >- substate = 1; >- } else if (this.calledFilesNames == null) { >- // >>>>>>>>>>>>>>>>>> Add the latest jar read >- addCurrentTokenJarWhenNecessary(currentJarToken); >- state = START; >- } else { >- // >>>>>>>>>>>>>>>>>> Add the latest jar read >- addCurrentTokenJarWhenNecessary(currentJarToken); >- state = SKIP_LINE; >- } >- break; >- case SKIP_LINE: >- if (currentChar == -1) { >- if (this.classpathSectionsCount != 0) { >- if (this.calledFilesNames == null) { >- return false; >+ 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) { >+ return true; >+ } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) { >+ state = IN_CLASSPATH_HEADER; >+ substate = 1; >+ } else { >+ state = SKIP_LINE; >+ } >+ break; >+ case IN_CLASSPATH_HEADER: >+ if (currentChar == -1) { >+ return true; >+ } else if (currentChar == '\n') { >+ state = START; >+ } else if (currentChar != CLASSPATH_HEADER_TOKEN[substate++]) { >+ state = SKIP_LINE; >+ } else if (substate == CLASSPATH_HEADER_TOKEN.length) { >+ state = PAST_CLASSPATH_HEADER; >+ } >+ break; >+ case PAST_CLASSPATH_HEADER: >+ if (currentChar == ' ') { >+ state = SKIPPING_WHITESPACE; >+ this.classpathSectionsCount++; >+ } else { >+ return false; >+ } >+ break; >+ case SKIPPING_WHITESPACE: >+ if (currentChar == -1) { >+ // >>>>>>>>>>>>>>>>>> Add the latest jar read >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ return true; >+ } else if (currentChar == '\n') { >+ state = CONTINUING; >+ } else if (currentChar != ' ') { >+ currentJarToken.append((char) currentChar); >+ state = READING_JAR; >+ } else { >+ // >>>>>>>>>>>>>>>>>> Add the latest jar read >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ } >+ break; >+ case CONTINUING: >+ if (currentChar == -1) { >+ // >>>>>>>>>>>>>>>>>> Add the latest jar read >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ return true; >+ } else if (currentChar == '\n') { >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ state = START; >+ } else if (currentChar == ' ') { >+ state = SKIPPING_WHITESPACE; >+ } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) { >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ state = IN_CLASSPATH_HEADER; >+ substate = 1; >+ } else if (this.calledFilesNames == null) { >+ // >>>>>>>>>>>>>>>>>> Add the latest jar read >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ state = START; >+ } else { >+ // >>>>>>>>>>>>>>>>>> Add the latest jar read >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ state = SKIP_LINE; >+ } >+ break; >+ case SKIP_LINE: >+ if (currentChar == -1) { >+ if (this.classpathSectionsCount != 0) { >+ if (this.calledFilesNames == null) { >+ return false; >+ } > } >+ return true; >+ } else if (currentChar == '\n') { >+ state = START; >+ } >+ break; >+ case READING_JAR: >+ if (currentChar == -1) { >+ // >>>>>>>>>>>>>>>>>> Add the latest jar read >+ return false; >+ } else if (currentChar == '\n') { >+ // appends token below >+ state = CONTINUING; >+ // >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line >+ break; >+ } else if (currentChar == ' ') { >+ // appends token below >+ state = SKIPPING_WHITESPACE; >+ } else { >+ currentJarToken.append((char) currentChar); >+ break; > } >- return true; >- } else if (currentChar == '\n') { >- state = START; >- } >- break; >- case READING_JAR: >- if (currentChar == -1) { >- // >>>>>>>>>>>>>>>>>> Add the latest jar read >- return false; >- } else if (currentChar == '\n') { >- // appends token below >- state = CONTINUING; >- // >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line >- break; >- } else if (currentChar == ' ') { >- // appends token below >- state = SKIPPING_WHITESPACE; >- } else { >- currentJarToken.append((char) currentChar); >- break; >- } >- addCurrentTokenJarWhenNecessary(currentJarToken); >- break; >+ addCurrentTokenJarWhenNecessary(currentJarToken); >+ break; >+ } > } >+ } finally { >+ reader.close(); > } > } > >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java,v >retrieving revision 1.1 >diff -u -r1.1 ManifestAnalyzerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java 4 Mar 2009 16:13:47 -0000 1.1 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java 17 Apr 2009 20:05:51 -0000 >@@ -10,8 +10,9 @@ > * IBM Corporation - code review and integration > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; >+import java.io.ByteArrayInputStream; > import java.io.IOException; >-import java.io.StringReader; >+import java.io.InputStream; > import java.util.List; > > import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer; >@@ -29,17 +30,23 @@ > } > public void testWithOneJar() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithOneJar); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithOneJar); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 1, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); > } > >+ private void analyzeManifestContents(String contents) throws IOException { >+ InputStream stream = new ByteArrayInputStream(contents.getBytes()); >+ try { >+ this.manifestAnalyzer.analyzeManifestContents(stream); >+ } catch(IOException e) { >+ stream.close(); >+ } >+ } > public void testWithOneJarWithWiteSpace() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithOneJarWithWiteSpace); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithOneJarWithWiteSpace); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 1, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -47,8 +54,7 @@ > > public void testWithSecondJarOnNextLine() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnNextLine); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnNextLine); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -57,8 +63,7 @@ > > public void testWithSecondJarOnTwoLine() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLine); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLine); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -67,8 +72,7 @@ > > public void testWithSecondJarOnTwoLine2() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLine); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLine); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 3, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -78,8 +82,7 @@ > > public void testWithSecondJarOnTwoLine3() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLine); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLine); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -88,8 +91,7 @@ > > public void testWithSecondJarOnTwoLine4() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLine); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLine); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 1, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -97,8 +99,7 @@ > > public void testWithSecondJarOnNextLine5() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnNextLine); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnNextLine); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 1, jars.size()); > assertEquals(FIRST_JAR + SECOND_JAR, jars.get(0)); >@@ -106,8 +107,7 @@ > > public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 1, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -115,8 +115,7 @@ > > public void testWithSecondJarOnTwoLineEndedWithEOF2() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -125,8 +124,7 @@ > > public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException { > 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 "; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -135,8 +133,7 @@ > > public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); >@@ -145,11 +142,19 @@ > > public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException { > 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"; >- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithNewLineEOF); >- this.manifestAnalyzer.analyzeManifestContents(reader); >+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithNewLineEOF); > List jars = this.manifestAnalyzer.getCalledFileNames(); > assertEquals("Wrong size", 2, jars.size()); > assertEquals(FIRST_JAR, jars.get(0)); > assertEquals(SECOND_JAR, jars.get(1)); > } >+ >+ public void testWithOneJarUsingUTF8Name() throws IOException { >+ InputStream inputStream = ManifestAnalyzerTest.class.getResourceAsStream("MANIFEST.MF"); >+ this.manifestAnalyzer.analyzeManifestContents(inputStream); >+ inputStream.close(); >+ List jars = this.manifestAnalyzer.getCalledFileNames(); >+ assertEquals("Wrong size", 1, jars.size()); >+ assertEquals("called\u3042.jar", jars.get(0)); >+ } > } >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.185 >diff -u -r1.185 BatchCompilerTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 10 Dec 2008 17:42:07 -0000 1.185 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Apr 2009 20:05:51 -0000 >@@ -12,10 +12,12 @@ > package org.eclipse.jdt.core.tests.compiler.regression; > > import java.io.BufferedReader; >+import java.io.ByteArrayInputStream; > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileOutputStream; > import java.io.IOException; >+import java.io.InputStream; > import java.io.PrintWriter; > import java.io.StringReader; > import java.text.MessageFormat; >@@ -10518,13 +10520,13 @@ > public void test268_jar_ref_in_jar(){ > try { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertTrue(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: lib1.jar\n" + >- "\n" + >- "Class-Path: lib3.jar\n"))); >+ assertTrue(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: lib1.jar\n" + >+ "\n" + >+ "Class-Path: lib3.jar\n")); > assertEquals(2, analyzer.getClasspathSectionsCount()); > assertEquals(2, analyzer.getCalledFileNames().size()); > } catch (IOException e) { >@@ -10539,13 +10541,13 @@ > public void test269_jar_ref_in_jar(){ > try { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertTrue(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: lib1.jar\n" + >- "Dummy:\n" + >- "Class-Path: lib3.jar\n"))); >+ assertTrue(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: lib1.jar\n" + >+ "Dummy:\n" + >+ "Class-Path: lib3.jar\n")); > assertEquals(2, analyzer.getClasspathSectionsCount()); > assertEquals(2, analyzer.getCalledFileNames().size()); > } catch (IOException e) { >@@ -10559,11 +10561,11 @@ > public void test270_jar_ref_in_jar(){ > try { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertTrue(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: lib1.jar\tlib2.jar\n"))); >+ assertTrue(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: lib1.jar\tlib2.jar\n")); > assertEquals(1, analyzer.getClasspathSectionsCount()); > assertEquals(1, analyzer.getCalledFileNames().size()); > } catch (IOException e) { >@@ -10600,13 +10602,13 @@ > public void test272_jar_ref_in_jar(){ > try { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertTrue(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: \n" + >- " lib1.jar \n" + >- "\n"))); >+ assertTrue(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: \n" + >+ " lib1.jar \n" + >+ "\n")); > assertEquals(1, analyzer.getClasspathSectionsCount()); > assertEquals(1, analyzer.getCalledFileNames().size()); > } catch (IOException e) { >@@ -10619,16 +10621,16 @@ > public void test273_jar_ref_in_jar(){ > try { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertTrue(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: \n" + >- " \n" + >- " lib1.jar \n" + >- " \n" + >- " lib1.jar \n" + >- "\n"))); >+ assertTrue(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: \n" + >+ " \n" + >+ " lib1.jar \n" + >+ " \n" + >+ " lib1.jar \n" + >+ "\n")); > assertEquals(1, analyzer.getClasspathSectionsCount()); > assertEquals(2, analyzer.getCalledFileNames().size()); > } catch (IOException e) { >@@ -10641,12 +10643,12 @@ > public void test274_jar_ref_in_jar(){ > try { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertFalse(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: \n" + >- " lib1.jar"))); >+ assertFalse(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: \n" + >+ " lib1.jar")); > } catch (IOException e) { > e.printStackTrace(); > fail(); >@@ -10656,28 +10658,37 @@ > // white-box test: variants on continuations > public void test275_jar_ref_in_jar(){ > try { >- assertFalse(new ManifestAnalyzer().analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: \n" + >- " \n" + >- " lib1.jar"))); >+ assertFalse(analyzeManifestContents( >+ new ManifestAnalyzer(), >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: \n" + >+ " \n" + >+ " lib1.jar")); > } catch (IOException e) { > e.printStackTrace(); > fail(); > } > } >+private boolean analyzeManifestContents(ManifestAnalyzer manifestAnalyzer, >+ String string) throws IOException { >+ InputStream stream = new ByteArrayInputStream(string.getBytes()); >+ try { >+ return manifestAnalyzer.analyzeManifestContents(stream); >+ } finally { >+ stream.close(); >+ } >+} > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars > // white-box test: variants on continuations > public void test276_jar_ref_in_jar(){ > try { >- assertFalse(new ManifestAnalyzer().analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\n" + >- "Created-By: Eclipse JDT Test Harness\n" + >- "Class-Path: \n" + >- "lib1.jar"))); >+ assertFalse(analyzeManifestContents( >+ new ManifestAnalyzer(), >+ "Manifest-Version: 1.0\n" + >+ "Created-By: Eclipse JDT Test Harness\n" + >+ "Class-Path: \n" + >+ "lib1.jar")); > } catch (IOException e) { > e.printStackTrace(); > fail(); >@@ -11031,13 +11042,13 @@ > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 > public void test291_jar_ref_in_jar() throws Exception { > ManifestAnalyzer analyzer = new ManifestAnalyzer(); >- assertTrue(analyzer.analyzeManifestContents( >- new StringReader( >- "Manifest-Version: 1.0\r\n" + >- "Created-By: Eclipse JDT Test Harness\r\n" + >- "Class-Path: \r\n" + >- "\r\n" >- ))); >+ assertTrue(analyzeManifestContents( >+ analyzer, >+ "Manifest-Version: 1.0\r\n" + >+ "Created-By: Eclipse JDT Test Harness\r\n" + >+ "Class-Path: \r\n" + >+ "\r\n" >+ )); > List calledFileNames = analyzer.getCalledFileNames(); > String actual = calledFileNames == null ? "<null>" : Util.toString((String[]) calledFileNames.toArray(new String[calledFileNames.size()]), false/*don't add extra new lines*/); > assertStringEquals( >Index: src/org/eclipse/jdt/core/tests/compiler/regression/MANIFEST.MF >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/compiler/regression/MANIFEST.MF >diff -N src/org/eclipse/jdt/core/tests/compiler/regression/MANIFEST.MF >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/MANIFEST.MF 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+Manifest-Version: 1.0 >+Class-Path: calledã?‚.jar >+Created-By: 1.6.0 (IBM Corporation) >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 272450
:
132034
|
132278
| 132292