Index: ClasspathJar.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java,v retrieving revision 1.33 diff -u -r1.33 ClasspathJar.java --- ClasspathJar.java 25 May 2005 14:15:06 -0000 1.33 +++ ClasspathJar.java 21 Jul 2005 14:28:05 -0000 @@ -15,6 +15,7 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.zip.ZipEntry; +import java.util.zip.ZipException; import java.util.zip.ZipFile; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; @@ -23,20 +24,30 @@ public class ClasspathJar extends ClasspathLocation { +File file; ZipFile zipFile; boolean closeZipFileAtEnd; Hashtable packageCache; public ClasspathJar(File file) throws IOException { - this(new ZipFile(file), true, null); + this(file, true, null); } -public ClasspathJar(ZipFile zipFile, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) { +public ClasspathJar(File file, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) { super(accessRuleSet); - this.zipFile = zipFile; + this.file = file; this.closeZipFileAtEnd = closeZipFileAtEnd; } public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) { + if (this.zipFile == null) { + try { + this.zipFile = new ZipFile(this.file); + } catch (ZipException e) { + return null; + } catch (IOException e) { + return null; + } + } if (!isPackage(qualifiedPackageName)) return null; // most common case @@ -75,18 +86,19 @@ public void reset() { if (this.zipFile != null && this.closeZipFileAtEnd) { try { - this.zipFile.close(); + this.zipFile.close(); } catch(IOException e) { // ignore } + this.zipFile = null; } this.packageCache = null; } public String toString() { - return "Classpath for jar file " + this.zipFile.getName(); //$NON-NLS-1$ + return "Classpath for jar file " + this.file.getName(); //$NON-NLS-1$ } public String normalizedPath(){ - String rawName = this.zipFile.getName(); + String rawName = this.file.getName(); return rawName.substring(0, rawName.lastIndexOf('.')); } } Index: FileSystem.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java,v retrieving revision 1.32 diff -u -r1.32 FileSystem.java --- FileSystem.java 25 May 2005 14:15:06 -0000 1.32 +++ FileSystem.java 21 Jul 2005 14:28:05 -0000 @@ -12,7 +12,6 @@ import java.io.File; import java.io.IOException; -import java.util.zip.ZipFile; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; @@ -77,25 +76,21 @@ static Classpath getClasspath(String classpathName, String encoding, int classpathDirectoryMode, AccessRuleSet accessRuleSet) { Classpath result = null; - try { - File file = new File(convertPathSeparators(classpathName)); - if (file.isDirectory()) { - if (file.exists()) { - result = new ClasspathDirectory(file, encoding, - classpathDirectoryMode, accessRuleSet); - } - } else { - String lowercaseClasspathName = classpathName.toLowerCase(); - if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) - || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { - result = new ClasspathJar(new ZipFile(file), true, - accessRuleSet); - // will throw an IOException if file does not exist - } - } - } catch (IOException e) { - // result = null; -- this is already the case + File file = new File(convertPathSeparators(classpathName)); + if (file.isDirectory()) { + if (file.exists()) { + result = new ClasspathDirectory(file, encoding, + classpathDirectoryMode, accessRuleSet); + } + } else { + String lowercaseClasspathName = classpathName.toLowerCase(); + if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar) + || lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) { + result = new ClasspathJar(file, true, + accessRuleSet); + // will throw an IOException if file does not exist } + } return result; } private void initializeKnownFileNames(String[] initialFileNames) { @@ -174,7 +169,7 @@ return null; } public ClasspathJar getClasspathJar(File file) throws IOException { - return new ClasspathJar(new ZipFile(file), true, null); + return new ClasspathJar(file, true, null); } public boolean isPackage(char[][] compoundName, char[] packageName) { String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/'));