在 Java 9 中,模块之间不允许循环,因此 A 需要 B,但 B 不能需要 A。
但是,通过查看 JDK 代码库,我可以看到该java.management
模块包含 exports com.sun.jmx.remote.util to java.management.rmi;
,并且在java.management.rmi
模块中我看到了导出com.sun.jmx.remote.protocol.rmi to java.management;
为什么对导出语句放宽这个循环规则?
module java.management {
exports javax.management.remote;
exports javax.management.timer;
exports sun.management.counter to jdk.management.agent;
exports com.sun.jmx.remote.util to java.management.rmi;
exports com.sun.jmx.remote.security to jdk.management.agent, java.management.rmi;
exports sun.management to jdk.management, jdk.management.agent, jdk.jconsole;
exports javax.management.modelmbean;
exports com.sun.jmx.remote.internal to jdk.management.agent, java.management.rmi;
exports java.lang.management;
exports sun.management.counter.perf to jdk.management.agent;
exports javax.management;
exports javax.management.relation;
exports sun.management.spi to jdk.management;
exports javax.management.openmbean;
exports javax.management.monitor;
exports javax.management.loading;
uses javax.management.remote.JMXConnectorProvider;
uses javax.management.remote.JMXConnectorServerProvider;
uses sun.management.spi.PlatformMBeanProvider;
provides javax.security.auth.spi.LoginModule with com.sun.jmx.remote.security.FileLoginModule;
}
和
module java.management.rmi {
requires transitive java.management;
requires transitive java.rmi;
requires java.naming;
exports javax.management.remote.rmi;
exports com.sun.jmx.remote.protocol.rmi to java.management;
exports com.sun.jmx.remote.internal.rmi to jdk.management.agent;
provides javax.management.remote.JMXConnectorServerProvider with com.sun.jmx.remote.protocol.rmi.ServerProvider;
provides javax.management.remote.JMXConnectorProvider with com.sun.jmx.remote.protocol.rmi.ClientProvider;
}