Are cycles allowed between platform modules?

巧了我就是萌 提交于 2019-11-30 02:37:47

问题


This is the module declaration of the java.rmi module:

module java.rmi {
    requires java.base;
    requires java.logging;

    exports java.rmi.activation;
    exports com.sun.rmi.rmid to java.base; // <-- cycle
    ...
}

So, there is a cyclic dependency between java.rmi and java.base, right? Are cycles allowed between platform modules?


回答1:


The module system forbids statically declaring cycles with requires clauses. This is true for platform and application modules and the example you give does not violate that rule.

Requires clauses are just one source for readability edges in the module graph, though. Others are command line flags, reflection, requires transitive, and I'm sure there are more. Adding all these may result in cycles in the module graph and that is not forbidden.

In your concrete example the cycle is only created once java.base reads java.rmi, which could happen if it uses reflection on classes in com.sun.rmi.rmid.



来源:https://stackoverflow.com/questions/44104714/are-cycles-allowed-between-platform-modules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!