RFR: 8345259: Disallow ALL-MODULE-PATH without explicit --module-path
Severin Gehwolf
sgehwolf at openjdk.org
Tue Dec 17 19:56:44 UTC 2024
On Tue, 17 Dec 2024 18:42:22 GMT, Mandy Chung <mchung at openjdk.org> wrote:
> I propose to implement as described in https://openjdk.org/jeps/261#Limiting-the-observable-modules -- to limit the observable modules to those in the transitive closure of the named modules plus the modules specified via the `--add-modules` option. In other words, `--add-modules ALL-MODULE-PATH` adds all modules on module path to the observable set. It's easy to explain and understand and no difference when `--limit-modules` is combined with `--add-modules m1,m2,...` with named modules.
So this means `--limit-modules` has no meaning when `ALL-MODULE-PATH` is specified. It will be ignored.
Let `--module-path` `MP` be the observable module set `{a, b, c}`. Let `b` have a dependency on `jdk.net`. `a` and `c` don't have any dependency. Then all of the following are equivalent:
- `jlink --add-modules ALL-MODULE-PATH --module-path MP --limit-modules jdk.net`
- `jlink --add-modules ALL-MODULE-PATH --module-path MP --limit-modules b` (2)
- `jlink --add-modules ALL-MODULE-PATH --module-path MP --limit-modules java.base`
- `jlink --add-modules ALL-MODULE-PATH --module-path MP --limit-modules a`
- `jlink --add-modules ALL-MODULE-PATH --module-path MP --limit-modules c`
- `jlink --add-modules ALL-MODULE-PATH --module-path MP`
Note that one pre-existing test case verifies case (2) above. It asserts that the modules in the image only include the transitive closure of `b` (not including `a`, `c`). This would then change to also include `a` and `c`.
The proposal would essentially mean that `--limit-modules` would be ignored. A corollary of it would be that if the module path includes the `jmods` folder, it would always include all JDK modules plus any that are observable outside that set without any means to cut the list of included modules.
Fine by me, but in that case it should perhaps trigger a warning that `--limit-modules` is being ignored when `ALL-MODULE-PATH` is specified in `--add-modules`.
Is that what you are proposing?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22494#issuecomment-2549479745
More information about the core-libs-dev
mailing list