< prev index next >

src/jdk.rmic/share/classes/sun/tools/java/ClassPath.java

Print this page




 377                 files.put(name, ClassFile.newClassFile(zip, entry));
 378             }
 379         }
 380     }
 381 }
 382 
 383 // a ClassPathEntry that represents jrt file system
 384 final class JrtClassPathEntry extends ClassPathEntry {
 385     private final FileSystem fs;
 386     // module directory paths in jrt fs
 387     private final Set<Path> jrtModules;
 388     // package name to package directory path mapping (lazily filled)
 389     private final Map<String, Path> pkgDirs;
 390 
 391     JrtClassPathEntry(FileSystem fs) {
 392         this.fs = fs;
 393         this.jrtModules = new LinkedHashSet<>();
 394         this.pkgDirs = new HashMap<>();
 395 
 396         // fill in module directories at the root dir
 397         Path root = fs.getPath("/");
 398         try {
 399             try (DirectoryStream<Path> stream = Files.newDirectoryStream(root)) {
 400                 for (Path entry: stream) {
 401                     if (Files.isDirectory(entry))
 402                         jrtModules.add(entry);
 403                 }
 404             }
 405         } catch (IOException ioExp) {
 406             throw new UncheckedIOException(ioExp);
 407         }
 408     }
 409 
 410     void close() throws IOException {
 411     }
 412 
 413     // from pkgName (internal separator '/') to it's Path in jrtfs
 414     synchronized Path getPackagePath(String pkgName) throws IOException {
 415         // check the cache first
 416         if (pkgDirs.containsKey(pkgName)) {
 417             return pkgDirs.get(pkgName);




 377                 files.put(name, ClassFile.newClassFile(zip, entry));
 378             }
 379         }
 380     }
 381 }
 382 
 383 // a ClassPathEntry that represents jrt file system
 384 final class JrtClassPathEntry extends ClassPathEntry {
 385     private final FileSystem fs;
 386     // module directory paths in jrt fs
 387     private final Set<Path> jrtModules;
 388     // package name to package directory path mapping (lazily filled)
 389     private final Map<String, Path> pkgDirs;
 390 
 391     JrtClassPathEntry(FileSystem fs) {
 392         this.fs = fs;
 393         this.jrtModules = new LinkedHashSet<>();
 394         this.pkgDirs = new HashMap<>();
 395 
 396         // fill in module directories at the root dir
 397         Path root = fs.getPath("/modules");
 398         try {
 399             try (DirectoryStream<Path> stream = Files.newDirectoryStream(root)) {
 400                 for (Path entry: stream) {
 401                     if (Files.isDirectory(entry))
 402                         jrtModules.add(entry);
 403                 }
 404             }
 405         } catch (IOException ioExp) {
 406             throw new UncheckedIOException(ioExp);
 407         }
 408     }
 409 
 410     void close() throws IOException {
 411     }
 412 
 413     // from pkgName (internal separator '/') to it's Path in jrtfs
 414     synchronized Path getPackagePath(String pkgName) throws IOException {
 415         // check the cache first
 416         if (pkgDirs.containsKey(pkgName)) {
 417             return pkgDirs.get(pkgName);


< prev index next >