Are cycles allowed between platform modules?
Asked Answered
P

1

11

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?

Patel answered 22/5, 2017 at 4:32 Comment(2)
@Eugene com.sun.rmi is a package that is exported by the module java.rmiPatel
@Eugent java.rmi depends on java.base. But it also exports its package to java.base, so java.base apparently needs access to this package (otherwise that line of code didn't make sense).Patel
C
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.

Cosmetic answered 22/5, 2017 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.