### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core 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.35 diff -u -r1.35 ClasspathJar.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 28 Jul 2005 16:52:26 -0000 1.35 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java 9 Feb 2006 17:49:49 -0000 @@ -17,6 +17,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; @@ -27,6 +28,7 @@ private ZipFile zipFile; private boolean closeZipFileAtEnd; private Hashtable packageCache; +private char[] normalizedPath; public ClasspathJar(File file) throws IOException { this(file, true, null); @@ -90,9 +92,15 @@ public String toString() { return "Classpath for jar file " + this.file.getPath(); //$NON-NLS-1$ } -public String normalizedPath(){ - String rawName = this.file.getPath(); - return rawName.substring(0, rawName.lastIndexOf('.')); +public char[] normalizedPath() { + if (this.normalizedPath == null) { + char[] rawName = this.file.getPath().toCharArray(); + if (File.separatorChar == '\\') { + CharOperation.replace(rawName, '\\', '/'); + } + this.normalizedPath = CharOperation.subarray(rawName, 0, CharOperation.lastIndexOf('.', rawName)); + } + return this.normalizedPath; } public String getPath(){ return this.file.getPath(); Index: batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v retrieving revision 1.35 diff -u -r1.35 FileSystem.java --- batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 17 Jan 2006 09:35:50 -0000 1.35 +++ batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java 9 Feb 2006 17:49:49 -0000 @@ -12,6 +12,8 @@ import java.io.File; import java.io.IOException; +import java.util.HashSet; +import java.util.Set; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; @@ -21,7 +23,7 @@ public class FileSystem implements INameEnvironment, SuffixConstants { Classpath[] classpaths; - String[] knownFileNames; + Set knownFileNames; interface Classpath { NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName); @@ -37,7 +39,7 @@ * (resp. '.zip') extension for jar (resp. zip) files. * @return a normalized path for file based classpath entries */ - String normalizedPath(); + char[] normalizedPath(); /** * Return the path for file based classpath entries. This is an absolute path * ending with a file separator for directories, an absolute path including the '.jar' @@ -117,26 +119,28 @@ return result; } private void initializeKnownFileNames(String[] initialFileNames) { - this.knownFileNames = new String[initialFileNames.length]; + this.knownFileNames = new HashSet(initialFileNames.length * 2); for (int i = initialFileNames.length; --i >= 0;) { - String fileName = initialFileNames[i]; - String matchingPathName = null; - if (fileName.lastIndexOf(".") != -1) //$NON-NLS-1$ - fileName = fileName.substring(0, fileName.lastIndexOf('.')); // remove trailing ".java" - - fileName = convertPathSeparators(fileName); + char[] fileName = initialFileNames[i].toCharArray(); + char[] matchingPathName = null; + final int lastIndexOf = CharOperation.lastIndexOf('.', fileName); + if (lastIndexOf != -1) { + fileName = CharOperation.subarray(fileName, 0, lastIndexOf); + } + CharOperation.replace(fileName, '\\', '/'); for (int j = 0; j < classpaths.length; j++){ - String matchCandidate = this.classpaths[j].normalizedPath(); + char[] matchCandidate = this.classpaths[j].normalizedPath(); if (this.classpaths[j] instanceof ClasspathDirectory && - fileName.startsWith(matchCandidate) && - (matchingPathName == null || - matchCandidate.length() < matchingPathName.length())) + CharOperation.prefixEquals(matchCandidate, fileName) && + (matchingPathName == null || + matchCandidate.length < matchingPathName.length)) matchingPathName = matchCandidate; } - if (matchingPathName == null) - this.knownFileNames[i] = fileName; // leave as is... - else - this.knownFileNames[i] = fileName.substring(matchingPathName.length()); + if (matchingPathName == null) { + this.knownFileNames.add(new String(fileName)); // leave as is... + } else { + this.knownFileNames.add(new String(CharOperation.subarray(fileName, matchingPathName.length, fileName.length))); + } matchingPathName = null; } } @@ -150,9 +154,7 @@ : path.replace('/', '\\'); } private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName){ - for (int i = 0, length = this.knownFileNames.length; i < length; i++) - if (qualifiedTypeName.equals(this.knownFileNames[i])) - return null; // looking for a file which we know was provided at the beginning of the compilation + if (this.knownFileNames.contains(qualifiedTypeName)) return null; // looking for a file which we know was provided at the beginning of the compilation String qualifiedBinaryFileName = qualifiedTypeName + SUFFIX_STRING_class; String qualifiedPackageName = Index: batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java,v retrieving revision 1.34 diff -u -r1.34 ClasspathDirectory.java --- batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 28 Jul 2005 16:52:26 -0000 1.34 +++ batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java 9 Feb 2006 17:49:49 -0000 @@ -14,16 +14,18 @@ import java.io.IOException; import java.util.Hashtable; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; public class ClasspathDirectory extends ClasspathLocation { -String path; -Hashtable directoryCache; -String[] missingPackageHolder = new String[1]; -String encoding; +private char[] normalizedPath; +private String path; +private Hashtable directoryCache; +private String[] missingPackageHolder = new String[1]; +private String encoding; public int mode; // ability to only consider one kind of files (source vs. binaries), by default use both public static final int SOURCE = 1; @@ -133,8 +135,14 @@ public String toString() { return "ClasspathDirectory " + this.path; //$NON-NLS-1$ } -public String normalizedPath() { - return this.path; +public char[] normalizedPath() { + if (this.normalizedPath == null) { + this.normalizedPath = this.path.toCharArray(); + if (File.separatorChar == '\\') { + CharOperation.replace(this.normalizedPath, '\\', '/'); + } + } + return this.normalizedPath; } public String getPath() { return this.path; Index: batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java,v retrieving revision 1.27 diff -u -r1.27 CompilationUnit.java --- batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java 23 Feb 2005 02:47:58 -0000 1.27 +++ batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java 9 Feb 2006 17:49:49 -0000 @@ -25,27 +25,27 @@ public CompilationUnit(char[] contents, String fileName, String encoding) { this.contents = contents; - if (File.separator.equals("/")) { //$NON-NLS-1$ - if (fileName.indexOf("\\") != -1) { //$NON-NLS-1$ - fileName = fileName.replace('\\', File.separatorChar); - } - } else { - // the file separator is \ - if (fileName.indexOf('/') != -1) { - fileName = fileName.replace('/', File.separatorChar); - } + char[] fileNameCharArray = fileName.toCharArray(); + switch(File.separatorChar) { + case '/' : + if (CharOperation.indexOf('\\', fileNameCharArray) != -1) { + CharOperation.replace(fileNameCharArray, '\\', '/'); + } + break; + case '\\' : + if (CharOperation.indexOf('/', fileNameCharArray) != -1) { + CharOperation.replace(fileNameCharArray, '/', '\\'); + } } - this.fileName = fileName.toCharArray(); + this.fileName = fileNameCharArray; + int start = CharOperation.lastIndexOf(File.separatorChar, fileNameCharArray) + 1; - int start = fileName.lastIndexOf("/") + 1; //$NON-NLS-1$ - if (start == 0 || start < fileName.lastIndexOf("\\")) //$NON-NLS-1$ - start = fileName.lastIndexOf("\\") + 1; //$NON-NLS-1$ - - int end = fileName.lastIndexOf("."); //$NON-NLS-1$ - if (end == -1) - end = fileName.length(); + int end = CharOperation.lastIndexOf('.', fileNameCharArray); + if (end == -1) { + end = fileNameCharArray.length; + } - this.mainTypeName = fileName.substring(start, end).toCharArray(); + this.mainTypeName = CharOperation.subarray(fileNameCharArray, start, end); this.encoding = encoding; } public char[] getContents() {