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

Christian Stein cstein at openjdk.org
Mon Jan 26 08:36:39 UTC 2026


> Please review this change to make `jar --validate` check an automatic module name given in a manifest file, via the `Automatic-Module-Name` attribute.
> 
> Prior to this commit, a `MANFEST.MF` reading
> 
> Automatic-Module-Name: default
> 
> added into a JAR file named `a.jar` would not fail when passed to `jar --validate --file a.jar`. However, it does fail when the JAR file is put on the module path of the Java launcher. For example:
> 
> $ java --module-path a.jar --describe-module default
> 
> Error occurred during initialization of boot layer
> java.lang.module.FindException: Unable to derive module descriptor for a.jar
> Caused by: java.lang.module.FindException: Automatic-Module-Name: default: Invalid module name: 'default' is not a Java identifier
> 
> 
> With this change applied, `jar --validate --file a.jar` will print an error message and return a non-zero exit value:
> 
> 
> invalid module name of Automatic-Module-Name entry in manifest: default
> 
> 
> The new check also fails for when the module name of a compiled module descriptor differs from the value given in the manifest file of the same JAR file.

Christian Stein has updated the pull request incrementally with one additional commit since the last revision:

  Address review comments

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29316/files
  - new: https://git.openjdk.org/jdk/pull/29316/files/9ca4567d..54f12744

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29316&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29316&range=00-01

  Stats: 69 lines in 3 files changed: 32 ins; 28 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/29316.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29316/head:pull/29316

PR: https://git.openjdk.org/jdk/pull/29316


More information about the core-libs-dev mailing list