Are cycles allowed between platform modules?

前端 未结 1 1245
悲&欢浪女
悲&欢浪女 2021-01-04 12:29

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

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

    exports java.rm         


        
相关标签:
1条回答
  • 2021-01-04 13:10

    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.

    0 讨论(0)
提交回复
热议问题