Are loops allowed between Java platform modules?

This is Java Module declaration of 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, Java RMI and Java There is a circular dependency between bases, right? Is the cycle allowed between platform modules?

Solution

The module system prohibits the use of require statements to statically declare loops This is true for platform and application modules, and the example you give does not violate this rule

However, the requires clause is only a source of readability edges in module graphics Others are command line flags, reflection, and need to be passed. I believe there are more Adding all of these may cause loops in the module diagram and will not be prohibited

In the specific example, only in Java Base read Java RMI will create a loop, if in com sun. rmi. This can happen if you use reflection on classes in rmid

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>