问题
Why does the Java 9 compiler warn "requires directive for an automatic module" if module-info.java
references automatic modules with "Automatic-Module-Name" set? What's the risk of such modules?
This question isn't an exact duplicate of What is an automatic module? because the latter does not address the specific reasons behind the compiler warning I have referenced (the context of the question matters). That said, it is a useful link for follow-up reading.
回答1:
Quoting Remi Forax:
The main issue is that an automatic module can see classes from the classpath, but it also exports all its package so there is no encapsulation, and once you require one automatic module all automatic modules from the module path are visible.
So an automatic module is a great tool when you transitioned to the module world, but in fine, you do not want any automatic modules in you dependency graph.
来源:https://stackoverflow.com/questions/46750408/why-does-javac-complain-about-named-automatic-modules