RFR: 8268611: jar --validate should check targeted classes in MR-JAR files

Christian Stein cstein at openjdk.org
Thu Dec 12 12:10:35 UTC 2024


On Thu, 14 Nov 2024 11:57:52 GMT, Christian Stein <cstein at openjdk.org> wrote:

> Please review this change ensuring all targeted classes in a MR-JAR file should target the same or a lower classfile version.
> 
> For example, having compiled source files with `javac` 25 without using the `--release` option (or with `--release 25`) and trying to archive them via a `jar --create --file a.jar --release 9 ... --release 10 ...` command now fails with:
> 
> classfile release value of META-INF/versions/9/version/Version.class too high: 25
> classfile release value of META-INF/versions/10/version/Version.class too high: 25
> invalid multi-release jar file a.jar deleted
> 
> 
> This pull request contains fixes to existing tests which produced invalid MR-JAR files. Most of those fixes are achieved by adding an appropriate `--release N` option to the associated `javac` call. One of those fixes rewrites the classfile version bytes between the `javac` and `jar` calls.

Yes. It was and is specified, but not enforced at package/archive-time ... and always failed at runtime with a "class version error" or similar on a Java version "in between".

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

PR Comment: https://git.openjdk.org/jdk/pull/22103#issuecomment-2538723675


More information about the compiler-dev mailing list