RFR: 8296329: jar validator doesn't account for minor class file version

Jorn Vernee jvernee at openjdk.org
Tue Nov 15 14:21:03 UTC 2022


On Tue, 15 Nov 2022 01:52:14 GMT, Bo Zhang <duke at openjdk.org> wrote:

> As described in [JDK-8296329](https://bugs.openjdk.org/browse/JDK-8296329), previously, the jar validator compare the "version" to validate a multi-release jar. The "version" is a mix of the major and minor version fused into a single int, which might be a negative number with `--enable-preview` - this result in wrong comparison.
> 
> This PR fixes it by only comparing major versions.

Please assign the JBS ticket to yourself as well.

test/jdk/tools/jar/multiRelease/VersionValidatorTest.java line 107:

> 105:                 { "19", "20", "", true },
> 106:                 { "20", "19", "", false },
> 107:         };

My concern with this is that this will need to be updated after each release. Looks like there are also ways to directly alter the minor version of a class file, and I recommend doing that instead. See: https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java#L51

Also, there's one more negative case missing where the base version uses 20 + preview features, and the other version is 19.

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

PR: https://git.openjdk.org/jdk/pull/11153


More information about the core-libs-dev mailing list