我尝试了解如何实现自定义ModuleFinder。为此,我需要实现自定义的ModuleReference,对于ModuleReference,我需要实现ModuleReader。这是我的代码:
ModuleReference ref = new ModuleReference(moduleDescriptor, Paths.get(path).toUri()) {
@Override
public ModuleReader open() throws IOException {
ModuleReader moduleReader = new ModuleReader() {
@Override
public Optional<URI> find(String name) throws IOException {
//LINE X
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Stream<String> list() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void close() throws IOException {
throw new UnsupportedOperationException("Not supported yet.");
}
};
return moduleReader;
}
};
我不明白应该在LINE X
写什么。据我了解,该模块不是由JVM加载的,因此我必须给文件系统上jar内的资源提供URI吗?像/home/Sam/temp/foo-1.jar!META-INF/temp.txt
之类的东西?
答案 0 :(得分:0)
在此邮件线程http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-September/013924.html中可以找到ModuleReader的示例