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

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java (+4 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.compiler.batch;
11
package org.eclipse.jdt.internal.compiler.batch;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.util.Hashtable;
15
import java.util.Hashtable;
15
16
16
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
17
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
Lines 120-125 Link Here
120
	}
121
	}
121
	return null;
122
	return null;
122
}
123
}
124
public void initialize() throws IOException {
125
	// nothing to do
126
}
123
public boolean isPackage(String qualifiedPackageName) {
127
public boolean isPackage(String qualifiedPackageName) {
124
	return directoryList(qualifiedPackageName) != null;
128
	return directoryList(qualifiedPackageName) != null;
125
}
129
}
(-)batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java (-7 / +12 lines)
Lines 23-38 Link Here
23
23
24
public class ClasspathJar extends ClasspathLocation {
24
public class ClasspathJar extends ClasspathLocation {
25
	
25
	
26
ZipFile zipFile;
26
private File file;
27
boolean closeZipFileAtEnd;
27
private ZipFile zipFile;
28
Hashtable packageCache;
28
private boolean closeZipFileAtEnd;
29
private Hashtable packageCache;
29
30
30
public ClasspathJar(File file) throws IOException {
31
public ClasspathJar(File file) throws IOException {
31
	this(new ZipFile(file), true, null);
32
	this(file, true, null);
32
}
33
}
33
public ClasspathJar(ZipFile zipFile, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) {
34
public ClasspathJar(File file, boolean closeZipFileAtEnd, AccessRuleSet accessRuleSet) {
34
	super(accessRuleSet);
35
	super(accessRuleSet);
35
	this.zipFile = zipFile;
36
	this.file = file;
36
	this.closeZipFileAtEnd = closeZipFileAtEnd;
37
	this.closeZipFileAtEnd = closeZipFileAtEnd;
37
}
38
}
38
39
Lines 49-54 Link Here
49
	}
50
	}
50
	return null;
51
	return null;
51
}
52
}
53
public void initialize() throws IOException {
54
	this.zipFile = new ZipFile(this.file);
55
}
52
public boolean isPackage(String qualifiedPackageName) {
56
public boolean isPackage(String qualifiedPackageName) {
53
	if (this.packageCache != null)
57
	if (this.packageCache != null)
54
		return this.packageCache.containsKey(qualifiedPackageName);
58
		return this.packageCache.containsKey(qualifiedPackageName);
Lines 75-84 Link Here
75
public void reset() {
79
public void reset() {
76
	if (this.zipFile != null && this.closeZipFileAtEnd) {
80
	if (this.zipFile != null && this.closeZipFileAtEnd) {
77
		try { 
81
		try { 
78
			this.zipFile.close(); 
82
			this.zipFile.close();
79
		} catch(IOException e) {
83
		} catch(IOException e) {
80
			// ignore
84
			// ignore
81
		}
85
		}
86
		this.zipFile = null;
82
	}
87
	}
83
	this.packageCache = null;
88
	this.packageCache = null;
84
}
89
}
(-)batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java (-35 / +46 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 39-44 Link Here
39
		 * @return a normalized path for file based classpath entries
38
		 * @return a normalized path for file based classpath entries
40
		 */
39
		 */
41
		String normalizedPath();
40
		String normalizedPath();
41
		/**
42
		 * Initialize the entry
43
		 */
44
		void initialize() throws IOException;
42
	}
45
	}
43
/*
46
/*
44
	classPathNames is a collection is Strings representing the full path of each class path
47
	classPathNames is a collection is Strings representing the full path of each class path
Lines 49-101 Link Here
49
	this(classpathNames, initialFileNames, encoding, null);
52
	this(classpathNames, initialFileNames, encoding, null);
50
}
53
}
51
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, int[] classpathDirectoryModes) {
54
public FileSystem(String[] classpathNames, String[] initialFileNames, String encoding, int[] classpathDirectoryModes) {
52
	int classpathSize = classpathNames.length;
55
	final int classpathSize = classpathNames.length;
53
	this.classpaths = new Classpath[classpathSize];
56
	this.classpaths = new Classpath[classpathSize];
54
	int problemsOccured = 0;
57
	int counter = 0;
55
	for (int i = 0; i < classpathSize; i++) {
58
	for (int i = 0; i < classpathSize; i++) {
56
		this.classpaths[i] = getClasspath(classpathNames[i], encoding,
59
		Classpath classpath = getClasspath(classpathNames[i], encoding,
57
					classpathDirectoryModes == null ? 0
60
					classpathDirectoryModes == null ? 0
58
							: classpathDirectoryModes[i], null);
61
							: classpathDirectoryModes[i], null);
59
		if (this.classpaths[i] == null)
62
		try {
60
			problemsOccured++;
63
			classpath.initialize();
64
			this.classpaths[counter++] = classpath;
65
		} catch (IOException e) {
66
			// ignore
67
		}
61
	}
68
	}
62
	if (problemsOccured > 0) {
69
	if (counter != classpathSize) {
63
		Classpath[] newPaths = new Classpath[classpathSize - problemsOccured];
70
		System.arraycopy(this.classpaths, 0, (this.classpaths = new Classpath[counter]), 0, counter);
64
		for (int i = 0, current = 0; i < classpathSize; i++)
65
			if (this.classpaths[i] != null) {
66
				newPaths[current] = this.classpaths[i];
67
			}
68
		classpathSize = newPaths.length;
69
		this.classpaths = newPaths;
70
	}
71
	}
71
	initializeKnownFileNames(initialFileNames);
72
	initializeKnownFileNames(initialFileNames);
72
}
73
}
73
FileSystem(Classpath[] classpaths, String[] initialFileNames) {
74
FileSystem(Classpath[] paths, String[] initialFileNames) {
74
	this.classpaths = classpaths;
75
	final int length = paths.length;
76
	int counter = 0;
77
	this.classpaths = new FileSystem.Classpath[length];
78
	for (int i = 0; i < length; i++) {
79
		final Classpath classpath = paths[i];
80
		try {
81
			classpath.initialize();
82
			this.classpaths[counter++] = classpath;
83
		} catch(IOException exception) {
84
			// ignore
85
		}
86
	}
87
	if (counter != length) {
88
		// should not happen
89
		System.arraycopy(this.classpaths, 0, (this.classpaths = new FileSystem.Classpath[counter]), 0, counter);
90
	}
75
	initializeKnownFileNames(initialFileNames);
91
	initializeKnownFileNames(initialFileNames);
76
}
92
}
77
static Classpath getClasspath(String classpathName, String encoding,
93
static Classpath getClasspath(String classpathName, String encoding,
78
		int classpathDirectoryMode, AccessRuleSet accessRuleSet) {
94
		int classpathDirectoryMode, AccessRuleSet accessRuleSet) {
79
	Classpath result = null;
95
	Classpath result = null;
80
	try {
96
	File file = new File(convertPathSeparators(classpathName));
81
			File file = new File(convertPathSeparators(classpathName));
97
	if (file.isDirectory()) {
82
			if (file.isDirectory()) {
98
		if (file.exists()) {
83
				if (file.exists()) {
99
			result = new ClasspathDirectory(file, encoding,
84
					result = new ClasspathDirectory(file, encoding,
100
					classpathDirectoryMode, accessRuleSet);
85
							classpathDirectoryMode, accessRuleSet);
86
				}
87
			} else {
88
				String lowercaseClasspathName = classpathName.toLowerCase();
89
				if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
90
						|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
91
					result = new ClasspathJar(new ZipFile(file), true,
92
							accessRuleSet);
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
		}
101
		}
102
	} else {
103
		String lowercaseClasspathName = classpathName.toLowerCase();
104
		if (lowercaseClasspathName.endsWith(SUFFIX_STRING_jar)
105
				|| lowercaseClasspathName.endsWith(SUFFIX_STRING_zip)) {
106
			result = new ClasspathJar(file, true, accessRuleSet);
107
			// will throw an IOException if file does not exist
108
		}
109
	}
99
	return result;
110
	return result;
100
}
111
}
101
private void initializeKnownFileNames(String[] initialFileNames) {
112
private void initializeKnownFileNames(String[] initialFileNames) {
Lines 174-180 Link Here
174
	return null;
185
	return null;
175
}
186
}
176
public ClasspathJar getClasspathJar(File file) throws IOException {
187
public ClasspathJar getClasspathJar(File file) throws IOException {
177
	return new ClasspathJar(new ZipFile(file), true, null);
188
	return new ClasspathJar(file, true, null);
178
}
189
}
179
public boolean isPackage(char[][] compoundName, char[] packageName) {
190
public boolean isPackage(char[][] compoundName, char[] packageName) {
180
	String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/'));
191
	String qualifiedPackageName = new String(CharOperation.concatWith(compoundName, packageName, '/'));

Return to bug 104664