Multi-Release JAR runtime support

Hervé BOUTEMY herve.boutemy at
Tue Apr 19 01:49:45 UTC 2016

Hi OpenJDK Core Developers,

Today, to prepare a conference talk on Java 9 (DevoxxFR, on wednesday 20th), I 
tested once again Maven proposed layout to produce Multi-Release JARs:

And I added a little script (. to run the build then execute the 
resulting jar with JRE 7, 8 and 9.

As expected, JRE 7 and 8 gave the same result, since my JRE 8 isn't patched to 
support MR JARs (if there is a simple way to add support, don't hesitate to 
give me a pointer. Or if there is any standard Java 8 build that should 
support it).

But the unexpected part is that JRE 9, either classical or jigsaw, don't take 
advantage of the MR JAR: is this really expected, or did I do something wrong?



Here is the interesting part of the output of the script:

Archive:  multirelease/target/multirelease-0.8-SNAPSHOT.jar
    testing: META-INF/MANIFEST.MF     OK
    testing: base/Base.class          OK
    testing: mr/A.class               OK
    testing: META-INF/versions/8/mr/A.class   OK
    testing: META-INF/versions/9/mr/A.class   OK
No errors detected in compressed data of multirelease/target/multirelease-0.8-
# Run Multi Release JAR with JRE 7
$ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base

# Run Multi Release JAR with JRE 8
$ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base

# Run Multi Release JAR with JRE 9 classic
$ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base

# Run Multi Release JAR with JRE 9 Jigsaw
$ java -classpath multirelease/target/multirelease-0.8-SNAPSHOT.jar base.Base

More information about the core-libs-dev mailing list