Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8319842

The module-infos for --release data do not contain pre-set versions

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 22
    • tools
    • None
    • behavioral
    • minimal
    • Other
    • JDK

      Summary

      The module descriptors used when --release N is specified will specify module version N.

      Problem

      Currently, when compiling with --release N on JDK O, the module descriptors used may either a) use no module version (for N < O); or b) use the current JDK's module version (for N == O). In the latter case, the version may be e.g. in the form of 21 or 21.0.1, etc., depending on the update release. This is problematic when using JDK to produce reproducible builds for modularized project, as these versions are compiled into the project's module descriptors, and differ across JDK versions. Therefore, the user's module descriptors are not reproducible across JDK versions or even JDK update versions.

      For example, consider compiling:

      module m {}

      with --release 21. This will encode a version of the java.base module in the resulting module-info.class, and the encoded version will differ:

      JDK versionJDK 21-eaJDK 21 GAJDK 21.0.1-eaJDK 21.0.1JDK 22
      recorded java.base dependency version:21-ea2121.0.1-ea21.0.1<none>

      When -source 21 is used instead of --release 21, the recorded version will be (because the compilation runs against the runtime classfiles, not against the historical data):

      JDK versionJDK 21-eaJDK 21 GAJDK 21.0.1-eaJDK 21.0.1JDK 22 GA
      recorded java.base dependency version:21-ea2121.0.1-ea21.0.122

      Solution

      Always include a module version in module descriptors used when compiling with --release.

      Following the example above, the recorded versions will be:

      JDK versionJDK 21-eaJDK 21 GAJDK 21.0.1-eaJDK 21.0.1JDK 22
      recorded java.base dependency version:21-ea2121-ea2121

      When using -source 21 instead of --release 21, the recorded versions will remain as before (because the compilation runs against the runtime classfiles, not against the historical data):

      JDK versionJDK 21-eaJDK 21 GAJDK 21.0.1-eaJDK 21.0.1JDK 22 GA
      recorded java.base dependency version:21-ea2121.0.1-ea21.0.122

      Specification

      When compiling with --release N, the module descriptors will always specify N as a version. For pre-release builds, the version will be N-${pre-release-version}.

            darcy Joe Darcy
            jlahoda Jan Lahoda
            Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: