src/share/classes/com/sun/tools/javac/file/JavacFileManager.java

changeset 106
ceaa6549687a
parent 103
e571266ae14f
child 184
905e151a185a
equal deleted inserted replaced
104:5e89c4ca637c 106:ceaa6549687a
53 import java.util.EnumSet; 53 import java.util.EnumSet;
54 import java.util.HashMap; 54 import java.util.HashMap;
55 import java.util.Iterator; 55 import java.util.Iterator;
56 import java.util.Map; 56 import java.util.Map;
57 import java.util.Set; 57 import java.util.Set;
58 import java.util.concurrent.ConcurrentHashMap;
59 import java.util.zip.ZipFile; 58 import java.util.zip.ZipFile;
60 59
61 import javax.lang.model.SourceVersion; 60 import javax.lang.model.SourceVersion;
62 import javax.tools.FileObject; 61 import javax.tools.FileObject;
63 import javax.tools.JavaFileManager; 62 import javax.tools.JavaFileManager;
86 */ 85 */
87 public class JavacFileManager implements StandardJavaFileManager { 86 public class JavacFileManager implements StandardJavaFileManager {
88 87
89 boolean useZipFileIndex; 88 boolean useZipFileIndex;
90 89
91 private static boolean CHECK_ZIP_TIMESTAMP = false;
92 private static Map<File, Boolean> isDirectory = new ConcurrentHashMap<File, Boolean>();
93
94
95 public static char[] toArray(CharBuffer buffer) { 90 public static char[] toArray(CharBuffer buffer) {
96 if (buffer.hasArray()) 91 if (buffer.hasArray())
97 return ((CharBuffer)buffer.compact().flip()).array(); 92 return ((CharBuffer)buffer.compact().flip()).array();
98 else 93 else
99 return buffer.toString().toCharArray(); 94 return buffer.toString().toCharArray();
107 /** Encapsulates knowledge of paths 102 /** Encapsulates knowledge of paths
108 */ 103 */
109 private Paths paths; 104 private Paths paths;
110 105
111 private Options options; 106 private Options options;
107
108 private FSInfo fsInfo;
112 109
113 private final File uninited = new File("U N I N I T E D"); 110 private final File uninited = new File("U N I N I T E D");
114 111
115 private final Set<JavaFileObject.Kind> sourceOrClass = 112 private final Set<JavaFileObject.Kind> sourceOrClass =
116 EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS); 113 EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS);
170 // have been set with setLocation, etc. 167 // have been set with setLocation, etc.
171 paths.setContext(context); 168 paths.setContext(context);
172 } 169 }
173 170
174 options = Options.instance(context); 171 options = Options.instance(context);
172 fsInfo = FSInfo.instance(context);
175 173
176 useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null; 174 useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null;
177 CHECK_ZIP_TIMESTAMP = System.getProperty("checkZipIndexTimestamp") != null;// TODO: options.get("checkZipIndexTimestamp") != null;
178 175
179 mmappedIO = options.get("mmappedIO") != null; 176 mmappedIO = options.get("mmappedIO") != null;
180 ignoreSymbolFile = options.get("ignore.symbol.file") != null; 177 ignoreSymbolFile = options.get("ignore.symbol.file") != null;
181 } 178 }
182 179
287 Set<JavaFileObject.Kind> fileKinds, 284 Set<JavaFileObject.Kind> fileKinds,
288 boolean recurse, 285 boolean recurse,
289 ListBuffer<JavaFileObject> l) { 286 ListBuffer<JavaFileObject> l) {
290 Archive archive = archives.get(directory); 287 Archive archive = archives.get(directory);
291 288
292 boolean isFile = false; 289 boolean isFile = fsInfo.isFile(directory);
293 if (CHECK_ZIP_TIMESTAMP) {
294 Boolean isf = isDirectory.get(directory);
295 if (isf == null) {
296 isFile = directory.isFile();
297 isDirectory.put(directory, isFile);
298 }
299 else {
300 isFile = directory.isFile();
301 }
302 }
303 else {
304 isFile = directory.isFile();
305 }
306 290
307 if (archive != null || isFile) { 291 if (archive != null || isFile) {
308 if (archive == null) { 292 if (archive == null) {
309 try { 293 try {
310 archive = openArchive(directory); 294 archive = openArchive(directory);

mercurial