RFR: 8375433: jar should validate automatic module names [v2]

Jorn Vernee jvernee at openjdk.org
Tue Jan 27 14:03:18 UTC 2026


On Tue, 27 Jan 2026 11:47:04 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> src/jdk.jartool/share/classes/sun/tools/jar/Validator.java line 480:
>> 
>>> 478:                 errorAndInvalid(formatMsg("error.validator.manifest.invalid.automatic.module.name", automaticModuleName));
>>> 479:             }
>>> 480:             if (md == null || automaticModuleName.equals(md.name())) {
>> 
>> Realizing this now, but this is only checking the top-level `module-info.class`, not any of the ones under the `META-INF/versions` directories. e.g. `checkModuleDescriptor` is also being called for each versioned `module-info.class` file. Is that something that we should also be doing for this check?
>
> The `this.md` field is initialized (by `checkModuleDescriptor(MODULE_INFO);` from within the constructor) to the "base" compiled module descriptor. It also includes this comment:
> 
>> ```
>>                // Initialize the base md if it's not yet. A "base" md can be either the
>>                // root module-info.class or the first versioned module-info.class
>> ```
> 
> With that in place, and the consistency checks being performed in `checkModuleDescriptor(MODULE_INFO);`, we are good.

I mean for cases where there are multiple module-info.class files. The automatic module name check only checks the first one, right?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29316#discussion_r2732153058


More information about the compiler-dev mailing list