db9e6cd
### Eclipse Workspace Patch 1.0
db9e6cd
#P org.eclipse.jdt.core
db9e6cd
Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
db9e6cd
===================================================================
db9e6cd
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java,v
db9e6cd
retrieving revision 1.45.2.1
db9e6cd
diff -u -r1.45.2.1 ClasspathJar.java
db9e6cd
--- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java	10 Nov 2008 17:46:09 -0000	1.45.2.1
db9e6cd
+++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java	4 Mar 2009 16:09:54 -0000
db9e6cd
@@ -1,5 +1,5 @@
db9e6cd
 /*******************************************************************************
db9e6cd
- * Copyright (c) 2000, 2008 IBM Corporation and others.
db9e6cd
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
db9e6cd
  * All rights reserved. This program and the accompanying materials
db9e6cd
  * are made available under the terms of the Eclipse Public License v1.0
db9e6cd
  * which accompanies this distribution, and is available at
db9e6cd
@@ -7,6 +7,7 @@
db9e6cd
  *
db9e6cd
  * Contributors:
db9e6cd
  *     IBM Corporation - initial API and implementation
db9e6cd
+ *     Fabrice Matrat - fix for 265103
db9e6cd
  *******************************************************************************/
db9e6cd
 package org.eclipse.jdt.internal.compiler.batch;
db9e6cd
 
db9e6cd
@@ -54,18 +55,20 @@
db9e6cd
 		READING_JAR = 4,
db9e6cd
 		CONTINUING = 5,
db9e6cd
 		SKIP_LINE = 6;
db9e6cd
-	private static final char[] CLASSPATH_HEADER_TOKEN = 
db9e6cd
+	private static final char[] CLASSPATH_HEADER_TOKEN =
db9e6cd
 		"Class-Path:".toCharArray(); //$NON-NLS-1$
db9e6cd
-	private int ClasspathSectionsCount;
db9e6cd
+	private int classpathSectionsCount;
db9e6cd
 	private ArrayList calledFilesNames;
db9e6cd
 	public boolean analyzeManifestContents(Reader reader) throws IOException {
db9e6cd
 		int state = START, substate = 0;
db9e6cd
 		StringBuffer currentJarToken = new StringBuffer();
db9e6cd
 		int currentChar;
db9e6cd
-		this.ClasspathSectionsCount = 0;
db9e6cd
+		this.classpathSectionsCount = 0;
db9e6cd
 		this.calledFilesNames = null;
db9e6cd
 		for (;;) {
db9e6cd
 			currentChar = reader.read();
db9e6cd
+			if (currentChar == '\r')  // skip \r, will consider \n later (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 )
db9e6cd
+				currentChar = reader.read();
db9e6cd
 			switch (state) {
db9e6cd
 				case START:
db9e6cd
 					if (currentChar == -1) {
db9e6cd
@@ -91,50 +94,71 @@
db9e6cd
 				case PAST_CLASSPATH_HEADER:
db9e6cd
 					if (currentChar == ' ') {
db9e6cd
 						state = SKIPPING_WHITESPACE;
db9e6cd
-						this.ClasspathSectionsCount++;
db9e6cd
+						this.classpathSectionsCount++;
db9e6cd
 					} else {
db9e6cd
 						return false;
db9e6cd
 					}
db9e6cd
 					break;
db9e6cd
 				case SKIPPING_WHITESPACE:
db9e6cd
 					if (currentChar == -1) {
db9e6cd
+						// >>>>>>>>>>>>>>>>>> Add the latest jar read
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 						return true;
db9e6cd
 					} else if (currentChar == '\n') {
db9e6cd
 						state = CONTINUING;
db9e6cd
 					} else if (currentChar != ' ') {
db9e6cd
 						currentJarToken.append((char) currentChar);
db9e6cd
 						state = READING_JAR;
db9e6cd
+					} else {
db9e6cd
+						// >>>>>>>>>>>>>>>>>> Add the latest jar read
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 					}
db9e6cd
 					break;
db9e6cd
 				case CONTINUING:
db9e6cd
 					if (currentChar == -1) {
db9e6cd
+						// >>>>>>>>>>>>>>>>>> Add the latest jar read
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 						return true;
db9e6cd
 					} else if (currentChar == '\n') {
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 						state = START;
db9e6cd
 					} else if (currentChar == ' ') {
db9e6cd
 						state = SKIPPING_WHITESPACE;
db9e6cd
 					} else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 						state = IN_CLASSPATH_HEADER;
db9e6cd
 						substate = 1;
db9e6cd
 					} else if (this.calledFilesNames == null) {
db9e6cd
-						return false;
db9e6cd
+						// >>>>>>>>>>>>>>>>>> Add the latest jar read
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
+						state = START;
db9e6cd
 					} else {
db9e6cd
+						// >>>>>>>>>>>>>>>>>> Add the latest jar read
db9e6cd
+						addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 						state = SKIP_LINE;
db9e6cd
 					}
db9e6cd
 					break;
db9e6cd
 				case SKIP_LINE:
db9e6cd
 					if (currentChar == -1) {
db9e6cd
+						if (this.classpathSectionsCount != 0) {
db9e6cd
+							if (this.calledFilesNames == null) {
db9e6cd
+								return false;
db9e6cd
+							}
db9e6cd
+						}
db9e6cd
 						return true;
db9e6cd
 					} else if (currentChar == '\n') {
db9e6cd
 						state = START;
db9e6cd
 					}
db9e6cd
 					break;
db9e6cd
-				case READING_JAR:	
db9e6cd
+				case READING_JAR:
db9e6cd
 					if (currentChar == -1) {
db9e6cd
+						// >>>>>>>>>>>>>>>>>> Add the latest jar read
db9e6cd
 						return false;
db9e6cd
 					} else if (currentChar == '\n') {
db9e6cd
 						// appends token below
db9e6cd
 						state = CONTINUING;
db9e6cd
+						// >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line
db9e6cd
+						break;
db9e6cd
 					} else if (currentChar == ' ') {
db9e6cd
 						// appends token below
db9e6cd
 						state = SKIPPING_WHITESPACE;
db9e6cd
@@ -142,17 +166,29 @@
db9e6cd
 						currentJarToken.append((char) currentChar);
db9e6cd
 						break;
db9e6cd
 					}
db9e6cd
-					if (this.calledFilesNames == null) {
db9e6cd
-						this.calledFilesNames = new ArrayList();
db9e6cd
-					}
db9e6cd
-					this.calledFilesNames.add(currentJarToken.toString());
db9e6cd
-					currentJarToken.setLength(0);
db9e6cd
+					addCurrentTokenJarWhenNecessary(currentJarToken);
db9e6cd
 					break;
db9e6cd
 			}
db9e6cd
-		}	
db9e6cd
+		}
db9e6cd
+	}	
db9e6cd
+	
db9e6cd
+	// >>>>>>>>>>>>>>>> Method Extracted from analyzeManifestContents in the READING_JAR Block
db9e6cd
+	private boolean addCurrentTokenJarWhenNecessary(StringBuffer currentJarToken) {
db9e6cd
+		if (currentJarToken != null && currentJarToken.length() > 0) {
db9e6cd
+			if (this.calledFilesNames == null) {
db9e6cd
+				this.calledFilesNames = new ArrayList();
db9e6cd
+			}
db9e6cd
+			this.calledFilesNames.add(currentJarToken.toString());
db9e6cd
+			currentJarToken.setLength(0);
db9e6cd
+			return true;
db9e6cd
+		}
db9e6cd
+		return false;
db9e6cd
 	}
db9e6cd
+	// <<<<<<<<<<<<<<<<<<<<<<
db9e6cd
+	
db9e6cd
+	
db9e6cd
 	public int getClasspathSectionsCount() {
db9e6cd
-		return this.ClasspathSectionsCount;
db9e6cd
+		return this.classpathSectionsCount;
db9e6cd
 	}
db9e6cd
 	public List getCalledFileNames() {
db9e6cd
 		return this.calledFilesNames;