< prev index next >
src/jdk.jdeps/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
Print this page
@@ -95,27 +95,36 @@
.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);
}
- Path home = Paths.get(System.getProperty("java.home"));
- Path mlib = home.resolve("lib").resolve("modules");
- if (Files.isDirectory(mlib)) {
- // jimage
+
+ if (isJrtAvailable()) {
+ // jrt file system
FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
- return new ImageHelper(fs, fs.getPath("/"));
+ return new ImageHelper(fs, fs.getPath("/modules"));
} else {
// exploded modules
- mlib = home.resolve("modules");
- if (!Files.isDirectory(mlib)) {
+ 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(mlib);
+ return new ImageHelper(exploded);
}
}
private final FileSystem fs;
private final Path mpath;
< prev index next >