RFR: 8318913: The module-infos for --release data do not contain pre-set versions [v4]

Jorge Solórzano duke at openjdk.org
Fri Nov 24 07:35:17 UTC 2023


On Mon, 20 Nov 2023 17:20:50 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Consider a simple module, like:
>> 
>> module test {}
>> 
>> 
>> And compile it with JDK 22 and JDK 21 using:
>> javac --release 21
>> 
>> The results of the compilations will differ: when compiling with JDK 21, the mandated java.base dependency will get a version, possibly like "21-internal". When compiling with JDK 22, the version of the java.base dependency will be empty.
>> 
>> This is a) because `module-info.class`es in `ct.sym` do not have any module version set; b) for JDK N, `--release N` is not using `ct.sym`, but rather `lib/modules`, which may contain a range of version specifiers.
>> 
>> This patch does two changes:
>> a) tweaks the `module-info.class`es in `ct.sym`, so that they contain a simple version. For `--release N`, the version is `N`.
>> b) tweaks the whole build so that `ct.sym` is used always for `--release`, a `lib/modules` is never used. I.e. the appropriate classfiles are copied into `ct.sym`. This not only allows for a general approach to module versions, but simplifies the `--release` handling in javac, and should enable future improvements. This is, however, a relatively big change.
>> 
>> The use of `lib/modules` for `--release <current>` was made to improve build performance, but the build has been updated since this has been introduced, so the slowdown caused by rebuilding `ct.sym` should be much lower now.
>> 
>> With these changes, compiling with `--release N` should record the same dependency versions in `module-info` on JDK N and JDK N + 1.
>
> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Reflecting review comment - removing unnecessary lines.

Hi, just some comments to get this clear, using Maven this issue [breaks the reproducible builds](https://issues.apache.org/jira/browse/MCOMPILER-542) since the JDK version is recorded on the module-info.class, breaking the reproducible build when using a different minor version.

In Maven there is a PR that will drop the version using ASM on the maven-compiler-plugin matching the behavior of building with JDK N+1.

With this change in the JDK, Maven could follow as long the recorded version is always the same on every minor release if the premise "For --release N, the version is N.", is fulfilled, in other words, it should always use the specification version (java.specification.version), this is to provide a workaround to this issue even for older JDK version.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16400#issuecomment-1824105718


More information about the compiler-dev mailing list