Add "source of module name" to ModuleDescriptor API
Alan Bateman
Alan.Bateman at oracle.com
Tue Jul 2 11:14:09 UTC 2019
On 02/07/2019 09:47, Christian Stein wrote:
> Hi,
>
> at the moment, class `java.lang.module.ModuleDescriptor` only
> provides an `isAutomatic()` getter -- which doesn't allow to
> determine from where the module name actually came from.
>
> Program `PresentModule.java` [1] creates a `JarFile` instance
> to determine the source of an automatic module.
>
> As the module name is resolved by the runtime from a
> specific source, it could be stored as a constant in the
> `ModuleDescriptor` instance at resolution time.
>
> I propose to extend the `ModuleDescriptor` class with a
>
> public enum NameSource {
> FILENAME, MANIFEST, DESCRIPTOR
> }
>
> and an accessor:
>
> public NameSource nameSource { return ... }
>
ModuleDescriptor just describes a named module and doesn't care how the
module name came about when creating an automatic module. Anything
working with module locations should use a ModuleReference as it defines
the "location" method to get a URI to the module content (if possible).
So probably better if tools like this used a ModuleReference and special
cased the JAR case when they want to know if the module name was
derived from the JAR file name or came from the value of the
Automatic-Module-Name attribute.
-Alan
More information about the jigsaw-dev
mailing list