Proposal: #AutomaticModuleNames

Sander Mak sander.mak at luminis.eu
Mon Apr 3 18:01:54 UTC 2017


>  - Do not implement the previous suggestion to define a `Module-Name`
>    manifest attribute [4][5].

I was already wondering why this feature hadn't made it to the jigsaw builds yet. However, I disagree that creating `module-info.class` files is just a bit more work than adding a Module-Name attribute. Apart from the logistics, making a named module imposes more constraints. Yes, the maintainer can just create an open module descriptor exporting all packages for the time being, mimicking its use as automatic module. But it won't be able to read the classpath like an automatic module. Nor will it get automatic readability to its dependencies, possibly deployed as (automatic) modules like it got with automatic modules. So, all the library's dependencies must be required in the module descriptor. Some of which may be not yet modularized themselves, so how would the library refer to them? 

Also, this approach makes it look as if the library author officially sanctions the use (reflective or otherwise) of all types by creating this open module with all packages exported. On the other hand, using the library as automatic module before it is modularized is a deliberate choice made by the library consumer. With the implied expectation that things might change once the library becomes a true module. If the library is published in the proposed 'in-between' form (with just a module descriptor to claim the module name), this implied expectation doesn't exist. A named module is a named module. I can already see the discussions emerge once the library maintainer starts with the real modularization. Which hopefully goes beyond the 'bit more work' done earlier to create the initial module descriptor to claim the module name, involving possible code changes to encapsulate internals and expose a nice API.

Being able to 'reserve' a module name with a one-line Pull Request sounds like a great feature to me, even if some people plot to use the same mechanism to hijack module names. Seems to me the baby gets thrown out with the bathwater here, weakening the migration story for library authors.


Sander


More information about the jpms-spec-observers mailing list