javac/jdeps and requires with version

Christian Stein sormuras at gmail.com
Fri Jan 10 10:52:24 UTC 2020


Hi,

given an empty module declaration:

  module foo{}

Compile it with javac using various valid "--release r" variants
yields different module descriptors in addition to the generated
class file version.

For JDK N, javac seems to include the version of a required
module only if you omit the release option or if you pass r = N.
For example, when having JDK 13.0.1 installed, the String
representation of module foo is:

  module { name: foo, [mandated java.base (@13.0.1)] }

For every r value with 9 <= r < N  it only reads:

   module { name: foo, [mandated java.base] }

What is the reason for this behaviour regarding
compiled version of requires directives?

Find the log of a MVE [1] at [2].

Additionally, I checked the following tools:

- "jdeps" also emits the version of "java.base"
- "jar --describe-module" does not emit the version of "java.base"
- "javap" does not emit the version of "java.base"

A side(?) effect of this can also be seen at [3], which
shows the result of running jdeps --check org.junit.platform.engine.
The only difference of the actual and the suggested
module descriptor are the versions attached to the
requires elements.

Cheers,
Christian

[1]: https://github.com/sormuras/sandbox/tree/master/java-compiled-versions

[2]: https://github.com/sormuras/sandbox/runs/383114037
[3]: https://github.com/junit-team/junit5/issues/2063#issuecomment-567015570


More information about the jigsaw-dev mailing list