|
16 | 16 |
|
17 | 17 | import java.io.ByteArrayInputStream; |
18 | 18 | import java.io.File; |
| 19 | +import java.io.FileNotFoundException; |
19 | 20 | import java.io.FileReader; |
20 | 21 | import java.io.IOException; |
21 | 22 | import java.io.InputStream; |
@@ -238,35 +239,67 @@ public static void reset() { |
238 | 239 | * @throws IOException |
239 | 240 | */ |
240 | 241 | public static void walkModuleImage(File image, final JRTUtil.JrtFileVisitor<java.nio.file.Path> visitor, int notify) throws IOException { |
241 | | - getJrtSystem(image, null).walkModuleImage(visitor, notify); |
| 242 | + JrtFileSystem system = getJrtSystem(image, null); |
| 243 | + if (system == null) { |
| 244 | + return; |
| 245 | + } |
| 246 | + system.walkModuleImage(visitor, notify); |
242 | 247 | } |
243 | 248 |
|
244 | 249 | public static void walkModuleImage(File image, String release, final JRTUtil.JrtFileVisitor<java.nio.file.Path> visitor, int notify) throws IOException { |
245 | | - getJrtSystem(image, release).walkModuleImage(visitor, notify); |
| 250 | + JrtFileSystem system = getJrtSystem(image, release); |
| 251 | + if (system == null) { |
| 252 | + return; |
| 253 | + } |
| 254 | + system.walkModuleImage(visitor, notify); |
246 | 255 | } |
247 | 256 |
|
248 | 257 | public static InputStream getContentFromJrt(File jrt, String fileName, String module) throws IOException { |
249 | | - return getJrtSystem(jrt).getContentFromJrt(fileName, module); |
| 258 | + JrtFileSystem system = getJrtSystem(jrt); |
| 259 | + if (system == null) { |
| 260 | + throw new FileNotFoundException(String.valueOf(jrt)); |
| 261 | + } |
| 262 | + return system.getContentFromJrt(fileName, module); |
250 | 263 | } |
251 | 264 |
|
252 | 265 | public static byte[] getClassfileContent(File jrt, String fileName, String module) throws IOException { |
253 | | - return getJrtSystem(jrt).getClassfileContent(fileName, module); |
| 266 | + JrtFileSystem system = getJrtSystem(jrt); |
| 267 | + if (system == null) { |
| 268 | + throw new FileNotFoundException(String.valueOf(jrt)); |
| 269 | + } |
| 270 | + return system.getClassfileContent(fileName, module); |
254 | 271 | } |
255 | 272 |
|
256 | 273 | public static ClassFileReader getClassfile(File jrt, String fileName, String module) throws IOException, ClassFormatException { |
257 | | - return getJrtSystem(jrt).getClassfile(fileName, module); |
| 274 | + JrtFileSystem system = getJrtSystem(jrt); |
| 275 | + if (system == null) { |
| 276 | + throw new FileNotFoundException(String.valueOf(jrt)); |
| 277 | + } |
| 278 | + return system.getClassfile(fileName, module); |
258 | 279 | } |
259 | 280 |
|
260 | 281 | public static ClassFileReader getClassfile(File jrt, String fileName, String module, Predicate<String> moduleNameFilter) throws IOException, ClassFormatException { |
261 | | - return getJrtSystem(jrt).getClassfile(fileName, module, moduleNameFilter); |
| 282 | + JrtFileSystem system = getJrtSystem(jrt); |
| 283 | + if (system == null) { |
| 284 | + throw new FileNotFoundException(String.valueOf(jrt)); |
| 285 | + } |
| 286 | + return system.getClassfile(fileName, module, moduleNameFilter); |
262 | 287 | } |
263 | 288 |
|
264 | 289 | public static List<String> getModulesDeclaringPackage(File jrt, String qName, String moduleName) { |
265 | | - return getJrtSystem(jrt).getModulesDeclaringPackage(qName, moduleName); |
| 290 | + JrtFileSystem system = getJrtSystem(jrt); |
| 291 | + if (system == null) { |
| 292 | + return List.of(); |
| 293 | + } |
| 294 | + return system.getModulesDeclaringPackage(qName, moduleName); |
266 | 295 | } |
267 | 296 |
|
268 | 297 | public static boolean hasCompilationUnit(File jrt, String qualifiedPackageName, String moduleName) { |
269 | | - return getJrtSystem(jrt).hasClassFile(qualifiedPackageName, moduleName); |
| 298 | + JrtFileSystem system = getJrtSystem(jrt); |
| 299 | + if (system == null) { |
| 300 | + return false; |
| 301 | + } |
| 302 | + return system.hasClassFile(qualifiedPackageName, moduleName); |
270 | 303 | } |
271 | 304 |
|
272 | 305 | /* |
|
0 commit comments