在即将到来的 Java 9 中,有没有办法动态发现哪些模块可用?
例如:
- 使用一些模块路径运行一些应用
- 在应用程序运行时,将更多模块添加到模块路径中(例如,复制到模块目录中)
- 在应用内,查询“给我所有可用的模块”(可能带有过滤器,例如那些提供相同服务的替代实现的模块)
我无法从文档中完全分辨出来。
最佳答案
我认为不支持这样的动态功能。目前,documentation of ModuleFinder.findAll()状态:
A
ModuleFinder
provides a consistent view of the modules that it locates. IffindAll
is invoked several times then it will return the same (equals) result each time.
关于java - JDK9有动态模块发现吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44335858/