JDK-8193346 : Multi-Release JARs are not working in exploded mode.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 9.0.1,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2017-12-09
  • Updated: 2017-12-12
Description
FULL PRODUCT VERSION :
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
This issue does not depend on the OS.

A DESCRIPTION OF THE PROBLEM :
Multi-Release JARs specification describes the structure and location of the classes for different Java versions.

The problem is that MRJars work only when they are packed as Jar files. When MRJar is exploded (the content is simply extracted and put on the classpath), MRJars are **not** working. Users are forced to create a jar file.

There is a huge impact of this bug: 1) we can **not** run tests, 2) we cannot run WARs application in Tomcat and so on.

Example: 

Developers are almost always running tests _before_ the code is packed into the jar! If you are building such MRJar, tests will not run for Java9, simply because there is no jar file.

Up to now, Jars were _always_ transparent. One could extract jars and put it on the classpath, and everything would still working. Not anymore with MRJArs.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
+ create a simple Gradle Java8 project
+ make a MR Jar structure, but adding Java9 classes in the "resources" folder, as per MRJar specification
+ add simple test that tests the code that is different for Java8 and Java9.

Run the tests on Java8 and Java9. Running tests on Java9 will not work (i.e. the java9 classes are not picked up).

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I am expecting that Java9 classes are picked up even they are **not** in the jar.
ACTUAL -
Java9 classes are not picked up.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Workaround would be to force users to create an artifact *before* it is tested, install it locally to local maven folder and then test it; which is totally unacceptable.


Comments
This is not a bug, it' really more of an enhancement request to support the equivalent of MR on the file system. For starters, there is no equivalent to "Multi-Release: true` as META-INF/MANIFEST.MF only make sense in a JAR file.
12-12-2017