73 @Override
74 public Node findNode(String path) throws IOException {
75 return image.findNode(path);
76 }
77 @Override
78 public byte[] getResource(Node node) throws IOException {
79 return image.getResource(node);
80 }
81 @Override
82 public void close() throws IOException {
83 image.close();
84 }
85 };
86 }
87
88 /** Internal factory method for testing only, use {@link SystemImage#open(PreviewMode)}. */
89 public static SystemImage fromDirectory(Path modulesDir, PreviewMode mode) throws IOException {
90 if (!Files.isDirectory(modulesDir)) {
91 throw new FileSystemNotFoundException(modulesDir.toString());
92 }
93 return new ExplodedImage(modulesDir);
94 }
95
96 private static final String RUNTIME_HOME;
97 // "modules" jimage file Path
98 private static final Path moduleImageFile;
99 // "modules" jimage exists or not?
100 private static final boolean modulesImageExists;
101 // <JAVA_HOME>/modules directory Path
102 private static final Path explodedModulesDir;
103
104 static {
105 PrivilegedAction<String> pa = SystemImage::findHome;
106 RUNTIME_HOME = AccessController.doPrivileged(pa);
107
108 FileSystem fs = FileSystems.getDefault();
109 moduleImageFile = fs.getPath(RUNTIME_HOME, "lib", "modules");
110 explodedModulesDir = fs.getPath(RUNTIME_HOME, "modules");
111
112 modulesImageExists = AccessController.doPrivileged(
113 new PrivilegedAction<Boolean>() {
|
73 @Override
74 public Node findNode(String path) throws IOException {
75 return image.findNode(path);
76 }
77 @Override
78 public byte[] getResource(Node node) throws IOException {
79 return image.getResource(node);
80 }
81 @Override
82 public void close() throws IOException {
83 image.close();
84 }
85 };
86 }
87
88 /** Internal factory method for testing only, use {@link SystemImage#open(PreviewMode)}. */
89 public static SystemImage fromDirectory(Path modulesDir, PreviewMode mode) throws IOException {
90 if (!Files.isDirectory(modulesDir)) {
91 throw new FileSystemNotFoundException(modulesDir.toString());
92 }
93 return new ExplodedImage(modulesDir, mode.isPreviewModeEnabled());
94 }
95
96 private static final String RUNTIME_HOME;
97 // "modules" jimage file Path
98 private static final Path moduleImageFile;
99 // "modules" jimage exists or not?
100 private static final boolean modulesImageExists;
101 // <JAVA_HOME>/modules directory Path
102 private static final Path explodedModulesDir;
103
104 static {
105 PrivilegedAction<String> pa = SystemImage::findHome;
106 RUNTIME_HOME = AccessController.doPrivileged(pa);
107
108 FileSystem fs = FileSystems.getDefault();
109 moduleImageFile = fs.getPath(RUNTIME_HOME, "lib", "modules");
110 explodedModulesDir = fs.getPath(RUNTIME_HOME, "modules");
111
112 modulesImageExists = AccessController.doPrivileged(
113 new PrivilegedAction<Boolean>() {
|