RFR: 8345259: When linking from the run-time image ALL-MODULE-PATH is not accepted
Mandy Chung
mchung at openjdk.org
Fri Dec 6 18:35:40 UTC 2024
On Mon, 2 Dec 2024 18:25:22 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
> Please review this bug fix for using `jlink` when linking from the run-time image. For regular JDK builds which include the `jmods` folder, that path is automatically added as the `--module-path` when not otherwise specified on the command line. For JDK builds with JEP 493 enabled, the `jmods` folder doesn't exist and the list of module roots needs to be computed from the system modules. However, since `jdk.jlink` isn't allowed to be added to the list of output modules when linking from the run-time image, the default module path doesn't include `jdk.jlink` and modules depending on `jdk.jlink`, currently only `jdk.jpackage`. This seems a sensible default since otherwise linking using ALL-MODULE-PATH fails, while it works with a JDK build including JMODs. See the bug for details about the issue.
>
> When an explicit module path is being added, there is no difference. All modules on that path will be added as roots. Tests have been added for the same. Thoughts?
>
> Testing:
> - [x] GHA, `test/jdk/tools/jlink` (all pass)
> - [x] Added jlink test.
Such behavioral change is a good change as jlink from the default and --generate-linkable-runtime build would have the consistent behavior. If a module path is given with no root module (empty path), it throws the following error. I think it can throw a similar message as if `--add-modules ALL-MODULE-PATH` is given but no `--module-path`.
$ jlink --add-modules ALL-MODULE-PATH --output myimage --module-path emptyPath
Error: Cannot invoke "java.nio.file.Path.getFileName()" because "javaBasePath" is null
java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.getFileName()" because "javaBasePath" is null
at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.isJavaBaseFromDefaultModulePath(JlinkTask.java:660)
at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.targetPlatform(JlinkTask.java:632)
at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImageProvider(JlinkTask.java:569)
at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImage(JlinkTask.java:410)
at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:285)
at jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:56)
at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:34)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22494#issuecomment-2523920827
More information about the core-libs-dev
mailing list