[javac] Option --release and compiled version of Requires

Christian Stein sormuras at gmail.com
Mon Oct 28 17:38:51 UTC 2019


why and how does the `--release n` option of `javac` control the compiled
version of ModuleDescriptor.Requires directive?

Take this simple module-info.java from a sample project at [*0]:

  module foo {}

My current observation is that if you omit the --release option [*1] or if
you pass n = N [*2], the current version N (its full version) is recorded
in the resulting module descriptor. [*3,*4]

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

If you pass a value of n, with n < N and N being the feature release number
of the current javac tool, the compiled version of the mandated "java.base"
module is dropped/lost in ... compilation. See [*5, *6] for `release 9[10]`
usages that produce the following ModuleDescriptor String-representation:

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

Is this behaviour expected?


[*0] https://github.com/sormuras/sandbox/tree/master/java-compiled-versions
[*5] https://github.com/sormuras/sandbox/runs/277876326#step:7:9
[*6] https://github.com/sormuras/sandbox/runs/277876326#step:8:9

More information about the jdk-dev mailing list