解决方法
唯一的模块名称 – 反向DNS
这里,假设模块名称应该是全局唯一的.鉴于这个目标,最实用的方法是遵循包命名策略,并反转维护者关联的域名. The State of the Module System says this:
Module names,like package names,must not conflict. The recommended way to name a module is to use the reverse-domain-name pattern that has long been recommended for naming packages.
此外,Mark Reinhold writes:
Strongly recommend that all modules be named according to the reverse Internet domain-name convention. A module’s name should correspond to the name of its principal exported API package,which should also follow that convention. If a module does not have such a package,or if for legacy reasons it must have a name that does not correspond to one of its exported packages,then its name should at least start with the reversed form of an Internet domain with which the author is associated.
这很清楚,由其他Java专家like Stephen Colebourne共享.
模块大于人工制品
有一段时间(2016年初),还有另一项推荐. JDK团队表示,模块名称可能不一定是唯一的,因为“因为模块比定义它们的工件更抽象”. Mark Reinhold writes:
Choose module names that start with the name of your project or product. Module (and package) names that start with reversed domain names are less likely to conflict but they’re unnecessarily verbose,they start with the least-important information (e.g.,
com
,org
,ornet
),and they don’t read well after exogenous changes such as open-source donations or corporate acquisitions (e.g.,com.sun.*
).The reversed domain-name approach was sensible in the early days of Java,before we had development tools sophisticated enough to help us deal with the occasional conflict. We have such tools now,so going forward the superior readability of short module and package names that start with project or product names is preferable to the onerous verbosity of those that start with reversed domain names.
另外,具有不包括域的模块名称将允许将该模块与另一个实现交换,只要它具有相同的名称(并且当然实现相同的公共API).
在上面的邮件里,Reinhold记录了他的意见变化:
Some people may prefer shorter,project-oriented names,and those can be fine to use in limited projects that will never,ever see the light of day outside of a single organization. If you create a module that has even a small chance of being open-sourced in the future,however,then the safest course is to choose a reverse-DNS name for it at the start.
概要
陪审团是在公众中公开表示反对的DNS一样的包装.