在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;
}