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

Collapse All | Expand All

(-)ClasspathJar.java (-6 / +18 lines)
Lines 15-20 Link Here
15
import java.util.Enumeration;
15
import java.util.Enumeration;
16
import java.util.Hashtable;
16
import java.util.Hashtable;
17
import java.util.zip.ZipEntry;
17
import java.util.zip.ZipEntry;
18
import java.util.zip.ZipException;
18
import java.util.zip.ZipFile;
19
import java.util.zip.ZipFile;
19
20
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
Lines 23-42 Link Here
23
24
24
public class ClasspathJar extends ClasspathLocation {
25
public class ClasspathJar extends ClasspathLocation {
25
	
26
	
27
File file;	
26
ZipFile zipFile;
28
ZipFile zipFile;
27
boolean closeZipFileAtEnd;
29
boolean closeZipFileAtEnd;
28
Hashtable packageCache;
30
Hashtable packageCache;
29
31
30
public ClasspathJar(File file) throws IOException {
32
public ClasspathJar(File file) throws IOException {
31
	this(new ZipFile(file), true, null);
33
	this(file, true, null);
32
}
34
}
33
public ClasspathJar(ZipFile zipFile, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) {
35
public ClasspathJar(File file, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) {
34
	super(accessRuleSet);
36
	super(accessRuleSet);
35
	this.zipFile = zipFile;
37
	this.file = file;
36
	this.closeZipFileAtEnd = closeZipFileAtEnd;
38
	this.closeZipFileAtEnd = closeZipFileAtEnd;
37
}
39
}
38
40
39
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) {
41
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) {
42
	if (this.zipFile == null) {
43
		try {
44
			this.zipFile = new ZipFile(this.file);
45
		} catch (ZipException e) {
46
			return null;
47
		} catch (IOException e) {
48
			return null;
49
		}
50
	}
40
	if (!isPackage(qualifiedPackageName)) 
51
	if (!isPackage(qualifiedPackageName)) 
41
		return null; // most common case
52
		return null; // most common case
42
53
Lines 75-92 Link Here
75
public void reset() {
86
public void reset() {
76
	if (this.zipFile != null && this.closeZipFileAtEnd) {
87
	if (this.zipFile != null && this.closeZipFileAtEnd) {
77
		try { 
88
		try { 
78
			this.zipFile.close(); 
89
			this.zipFile.close();
79
		} catch(IOException e) {
90
		} catch(IOException e) {
80
			// ignore
91
			// ignore
81
		}
92
		}
93
		this.zipFile = null;
82
	}
94
	}
83
	this.packageCache = null;
95
	this.packageCache = null;
84
}
96
}
85
public String toString() {
97
public String toString() {
86
	return "Classpath for jar file " + this.zipFile.getName(); //$NON-NLS-1$
98
	return "Classpath for jar file " + this.file.getName(); //$NON-NLS-1$
87
}
99
}
88
public String normalizedPath(){
100
public String normalizedPath(){
89
	String rawName = this.zipFile.getName();
101
	String rawName = this.file.getName();
90
	return rawName.substring(0, rawName.lastIndexOf('.'));
102
	return rawName.substring(0, rawName.lastIndexOf('.'));
91
}
103
}
92
}
104
}
(-)FileSystem.java (-20 / +15 lines)
Lines 12-18 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.zip.ZipFile;
16
15
17
import org.eclipse.jdt.core.compiler.CharOperation;
16
import org.eclipse.jdt.core.compiler.CharOperation;
18
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
17
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
Lines 77-101 Link Here
77
static Classpath getClasspath(String classpathName, String encoding,
76
static Classpath getClasspath(String classpathName, String encoding,
78
		int classpathDirectoryMode, AccessRuleSet accessRuleSet) {
77
		int classpathDirectoryMode, AccessRuleSet accessRuleSet) {
79
	Classpath result = null;
78
	Classpath result = null;
80
	try {
79
	File file = new File(convertPathSeparators(classpathName));
81
			File file = new File(convertPathSeparators(classpathName));
80
	if (file.isDirectory()) {
82
			if (file.isDirectory()) {
81
		if (file.exists()) {
83
				if (file.exists()) {
82
			result = new ClasspathDirectory(file, encoding,
84
					result = new ClasspathDirectory(file, encoding,
83
					classpathDirectoryMode, accessRuleSet);
85
							classpathDirectoryMode, accessRuleSet);
84
		}
86
				}
85
	} else {
87
			} else {
86
		String lowercaseClasspathName = classpathName.toLowerCase();
88
				String lowercaseClasspathName = classpathName.toLowerCase();
87
		if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
89
				if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
88
				|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
90
						|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
89
			result = new ClasspathJar(file, true,
91
					result = new ClasspathJar(new ZipFile(file), true,
90
					accessRuleSet);
92
							accessRuleSet);
91
			// will throw an IOException if file does not exist
93
					// will throw an IOException if file does not exist
94
				}
95
			}
96
		} catch (IOException e) {
97
			// result = null; -- this is already the case
98
		}
92
		}
93
	}
99
	return result;
94
	return result;
100
}
95
}
101
private void initializeKnownFileNames(String[] initialFileNames) {
96
private void initializeKnownFileNames(String[] initialFileNames) {
Lines 174-180 Link Here
174
	return null;
169
	return null;
175
}
170
}
176
public ClasspathJar getClasspathJar(File file) throws IOException {
171
public ClasspathJar getClasspathJar(File file) throws IOException {
177
	return new ClasspathJar(new ZipFile(file), true, null);
172
	return new ClasspathJar(file, true, null);
178
}
173
}
179
public boolean isPackage(char[][] compoundName, char[] packageName) {
174
public boolean isPackage(char[][] compoundName, char[] packageName) {
180
	String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/'));
175
	String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/'));

Return to bug 104664