< prev index next >
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
Print this page
*** 95,121 ****
.map(Archive::getInstance)
.collect(Collectors.toList());
}
static class ImageHelper {
static ImageHelper getInstance(Path mpath) throws IOException {
if (mpath != null) {
return new ImageHelper(mpath);
}
! Path home = Paths.get(System.getProperty("java.home"));
! Path mlib = home.resolve("lib").resolve("modules");
! if (Files.isDirectory(mlib)) {
! // jimage
FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
! return new ImageHelper(fs, fs.getPath("/"));
} else {
// exploded modules
! mlib = home.resolve("modules");
! if (!Files.isDirectory(mlib)) {
throw new InternalError(home + " not a modular image");
}
! return new ImageHelper(mlib);
}
}
private final FileSystem fs;
private final Path mpath;
--- 95,130 ----
.map(Archive::getInstance)
.collect(Collectors.toList());
}
static class ImageHelper {
+ private static boolean isJrtAvailable() {
+ try {
+ FileSystems.getFileSystem(URI.create("jrt:/"));
+ return true;
+ } catch (ProviderNotFoundException | FileSystemNotFoundException e) {
+ return false;
+ }
+ }
+
static ImageHelper getInstance(Path mpath) throws IOException {
if (mpath != null) {
return new ImageHelper(mpath);
}
!
! if (isJrtAvailable()) {
! // jrt file system
FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
! return new ImageHelper(fs, fs.getPath("/modules"));
} else {
// exploded modules
! String home = System.getProperty("java.home");
! Path exploded = Paths.get(home, "modules");
! if (!Files.isDirectory(exploded)) {
throw new InternalError(home + " not a modular image");
}
! return new ImageHelper(exploded);
}
}
private final FileSystem fs;
private final Path mpath;
< prev index next >