Why is it allowed to have several modules with the same name?

Gunnar Morling gunnar at hibernate.org
Sat Dec 26 16:58:04 UTC 2020


Why is this situation not considered an error though? Relying on ordering
on the module path seems to go against one of the core promises of the
module system: reliability and less "surprises".

--Gunnar


Am Sa., 26. Dez. 2020 um 17:27 Uhr schrieb Jonathan Gibbons <
jonathan.gibbons at oracle.com>:

> If the two modules with the same name are in different positions on the
> module path, the first one will be seen and will completely hide any
> subsequent occurrences of modules with the same name.
>
> If two modules with the same name are found in the same directory on the
> module path, such as in differently-named jar files, then that is an
> error, because neither can be said to have precedence and hide the other.
>
> -- Jon
>
> On 12/26/20 3:29 AM, Gunnar Morling wrote:
> > Hi,
> >
> > So far it was my assumption that the module system would reject
> > multiple modules with the same name to be present.
> >
> > But this seems not to be the case; if I have two versions of a module JAR
> > on my module path -- i.e. two modules which have the same module name and
> > export the same set of packages -- the java command does not complain
> (nor
> > does javac or jlink). Is this an expected behavior?
> >
> > Thanks,
> >
> > --Gunnar
>


More information about the jigsaw-dev mailing list