Add "source of module name" to ModuleDescriptor API

Christian Stein sormuras at gmail.com
Tue Jul 2 08:47:41 UTC 2019


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 ... }

Cheers,
Christian

[1] https://github.com/sormuras/modules/blob/master/src/PresentModule.java


More information about the jigsaw-dev mailing list