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

jar validator doesn't account for minor class file version

    • jar
    • behavioral
    • minimal
    • The jar tool will produce an error for invalid jar files that it previously failed to reject. However, this can only occur when class files with the high-order bit of their minor version set are involved, such as those compiled with preview features.
    • Other
    • JDK

      Summary

      Correct the behavior of the jar tool's validator when putting classes with a preview version into a META-INF/versions directory.

      Problem

      The jar tool's validator looks at the version of a class file in a META-INFA/versions/N directory, to see if the version is greater than the version of the base class file. This for instance prevents a versioned class file with version 17 from overwriting a base class file with version 19.

      However, due to a bug, a class file with major version 17 is allowed to override a class file with major version 19 + preview features. (which should not be allowed)

      Vice versa, a class file with major version 19 + preview features is not allowed to override a class file with major version 17. (which should be allowed)

      Solution

      The solution is to ignore the minor version when performing the check, which fixes the bug.

      The multi-release jar file mechanism (META-INF/versions dir) can only be used to override class files on a major version basis. The minor version is simply an irrelevant detail in this situation.

      Specification

      This is a behavior-only change. The jar tool's validator has no specification.

            jvernee Jorn Vernee
            jvernee Jorn Vernee
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: