Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are cycles allowed between platform modules?

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?

like image 844
ZhekaKozlov Avatar asked May 22 '17 04:05

ZhekaKozlov


People also ask

How do I modularize a Java project?

Adding Modules to the Unnamed Module For example, when we try to run Java 8 programs as-is with Java 9 compiler we may need to add modules. In general, the option to add the named modules to the default set of root modules is –add-modules <module>(,<module>)* where <module> is a module name.

What is modular design in Java?

What is Modularity in Java? A module is more like an independent partition of software that is communicated through an interface. Modularity explores the creation of a program by using different modules than a single legacy architecture.

What is module profile?

Module profiles. A profile is a list of recommended packages to be installed together for a particular use case such as for a server, client, development, minimal install, or other. These package lists can contain packages outside the module stream, usually from the BaseOS repository or the dependencies of the stream.


1 Answers

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.

like image 124
Nicolai Parlog Avatar answered Oct 21 '22 04:10

Nicolai Parlog