Why is it allowed to have several modules with the same name?
Alan Bateman
Alan.Bateman at oracle.com
Tue Dec 29 07:57:04 UTC 2020
On 27/12/2020 09:50, Gunnar Morling wrote:
> Thanks for clarifying, Alan. So it is intended and well-documented,
> it's still not quite clear to me though *why* that is. Wouldn#t it be
> more in line with the module system's goal of reliability to reject
> such error-prone configuration?
Reliable configuration is mostly about ensuring that there aren't
missing dependencies, cycles between dependencies, or split packages.
You get reliability with the module path by only reading the first
definition of a module. If someone put 10 versions of the same module on
the module path then classes will only be loaded from the first module,
unlike the class path where you risk loading classes from more than one
of the artifacts.
If it helps, the java --validate-modules option is useful for detecting
and reporting issues. It will print an informational message when there
are multiple definitions of a module on the module path.
-Alan
More information about the jigsaw-dev
mailing list