Let say there is module x
that exports something.
Then there is module a
:
module a {
exports some.package.from.a
requires transitive x;
}
Then there are 100 modules b
that require a
:
module b1 {
exports some.package.from.b1
requires a;
}
...
module b100 {
exports some.package.from.b100
requires a;
}
Then there are 100 modules c
that require respective b
s
module c1 {
requires b1;
}
...
module c100 {
requires b100;
}
Assume c1
... c100
do not need to know about packages from a
. Those are only used by b1
... b100
internally and thus not transitively required.
However the API exported by b1
... b100
uses classes in packages exported by x
.
Modules c1
... c100
can NOT see those. Trying to compile them, results in
Compilation failure:
(package x.y.z is declared in module x, but module c1 does not read it)
Why is requires transitive
limited to the modules that directly require the module containing it? How can the issue described above be solved without editing 100 module-info
files?
UPDATE: There are at least 3 ways to "fix" this:
- add
requires transitive a
tob1
...b100
- add
requires transitive x
tob1
...b100
- add
requires x
toc1
...c100
While all would work in this particular case, it is not clear which one should be used and what the side effects of each of them are. Moreover this is only 3 level deep hierarchy - with more levels, it gets even more complex.
If requires transitive
was to be transitive for all dependents (as the word transitive implies) this would be solved automatically. If there was no transitive
there would have been only one way to approach the issue. With transitive
limited to the direct dependents there are "options" which needs to considered, but it seams not enough information is provided for one to make proper choice.