Why does javac complain about named automatic-modules?

限于喜欢 提交于 2019-12-07 20:46:34

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!