On Thu, 14 Nov 2024 11:57:52 GMT, Christian Stein <cst...@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. The [JAR File 
> Specification](https://docs.oracle.com/javase/9/docs/specs/jar/jar.html#Multi-release)
>  of JavaSE 9 reads:
> 
>> A class file under a versioned directory, of version N say, in a 
>> multi-release JAR must have a class file version less than or equal to the 
>> class file version associated with Nth major version of a Java platform 
>> release.
> 
> 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:
> 
> META-INF/versions/9/com/foo/Bar.class has class file version 69.0, but class 
> file version 53.0 or less is required to target release 9 of the Java Platform
> 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.

This pull request has now been integrated.

Changeset: bd3c0be3
Author:    Christian Stein <cst...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/bd3c0be36d929fab5e5ca0158d53e50b2d206707
Stats:     156 lines in 14 files changed: 48 ins; 32 del; 76 mod

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

Reviewed-by: jvernee

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

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

Reply via email to