Summary
Disallow using jlink
with the ALL-MODULE-PATH
special value in --add-modules
when no --module-path
option is given or the --module-path
option only points to paths where no modules can be found (empty module paths).
Problem
Previously using this was possible for regular JDK builds:
jlink --add-modules ALL-MODULE-PATH --output image
In essence, it was equivalent to:
jlink --add-modules ALL-MODULE-PATH --module-path $JAVA_HOME/jmods --output image
So the result would have been a JDK with all modules included. However, with JEP 493 this would become problematic since $JAVA_HOME/jmods
no longer exists and, thus, jlink --add-modules ALL-MODULE-PATH --output image
would link with no modules included resulting in inconsistent behaviour.
Solution
In order to make JEP 493 enabled builds and regular JDK builds consistent in terms of ALL-MODULE-PATH
treatment, this special option will need to include an explicit --module-path
option. This may include $JAVA_HOME/jmods
(if existing) in order to achieve a similar result to the previous jlink --add-modules ALL-MODULE-PATH --output image
without --module-path
option.
What's more, empty or non-existent module paths result in the same error as when ALL-MODULE-PATH
is requested and no --module-path
has been provided.
Specification
ALL-MODULE-PATH
without an explicit --module-path
option is an error:
$ jlink --add-modules ALL-MODULE-PATH --output out-image
Error: --module-path option must be specified with --add-modules ALL-MODULE-PATH
ALL-MODULE-PATH
with --module-path
option(s), but directories that --module-path
point to don't have any observable modules it's also an error:
$ jlink --add-modules ALL-MODULE-PATH --module-path not-existing --output out-image
Error: No module found in module path 'not-existing' with --add-modules ALL-MODULE-PATH
When the module path exists and modules are observable there, ALL-MODULE-PATH
works as expected:
$ jlink --add-modules ALL-MODULE-PATH --module-path jmods/ --output out-image --verbose
com.foo.runtime file:///path/to/jmods/com.foo.runtime.jmod
java.base file:///path/to/jdk/jmods/java.base.jmod
jdk.jfr file:///path/to/jdk/jmods/jdk.jfr.jmod
Providers:
java.base provides java.nio.file.spi.FileSystemProvider used by java.base
Full details in https://github.com/openjdk/jdk/pull/22494
- csr of
-
JDK-8345259 Disallow ALL-MODULE-PATH without explicit --module-path
- Resolved