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

Alan Bateman Alan.Bateman at oracle.com
Sat Dec 26 18:03:42 UTC 2020


On 26/12/2020 16:26, Jonathan Gibbons wrote:
> 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.

Just to add to Jon's mail, there detail in in the "Module paths" section 
of JEP 261 [1] and the API docs of ModuleFinder.of(Path...) [2] which is 
the API for creating the equivalent of a module path to find modules.

-Alan.

[1] https://openjdk.java.net/jeps/261#Module-paths
[2] 
https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/module/ModuleFinder.html#of(java.nio.file.Path...)


More information about the jigsaw-dev mailing list