gpt4 book ai didi

java-9 - 为什么 javac 提示命名自动模块?

转载 作者:行者123 更新时间:2023-12-02 14:23:44 25 4
gpt4 key购买 nike

如果 module-info.java 引用设置了“Automatic-Module-Name”的自动模块,为什么 Java 9 编译器会警告“自动模块需要指令”?此类模块有什么风险?

此问题与 What is an automatic module? 不完全相同因为后者没有解决我引用的编译器警告背后的具体原因(问题的上下文很重要)。也就是说,这是后续阅读的有用链接。

最佳答案

引用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.

关于java-9 - 为什么 javac 提示命名自动模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46750408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com