(String path)
| 22 | } |
| 23 | |
| 24 | public URL findResource(String path) throws IOException { |
| 25 | URL url = ResourceFinder.class.getClassLoader().getResource(path); |
| 26 | if (url != null) { |
| 27 | return url; |
| 28 | } |
| 29 | |
| 30 | if (_moduleReader != null) { |
| 31 | return _moduleReader.map(reader -> _findResource(reader, path)).orElse(null); |
| 32 | } |
| 33 | |
| 34 | Optional<ModuleReference> moduleReference = ModuleFinder.ofSystem().find(_moduleName); |
| 35 | if (moduleReference.isPresent()) { |
| 36 | _moduleReader = Optional.of(moduleReference.get().open()); |
| 37 | return _findResource(_moduleReader.get(), path); |
| 38 | } |
| 39 | |
| 40 | String modulePath = System.getProperty("jdk.module.path"); |
| 41 | if (modulePath != null && !modulePath.isEmpty()) { |
| 42 | Path[] paths = Arrays.stream(modulePath.split(File.pathSeparator)) |
| 43 | .map(Paths::get) |
| 44 | .toArray(Path[]::new); |
| 45 | |
| 46 | moduleReference = ModuleFinder.of(paths).find(_moduleName); |
| 47 | if (moduleReference.isPresent()) { |
| 48 | _moduleReader = Optional.of(moduleReference.get().open()); |
| 49 | return _findResource(_moduleReader.get(), path); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | _moduleReader = Optional.empty(); |
| 54 | return null; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public void close() throws IOException { |
nothing calls this directly
no test coverage detected