1

Since Java 9 there are Multi-Release JARs (MRJARS) that allow different classes for different Java versions to be included in one JAR file. I was surprised when a Wildfly 14 running on Java 11 executed Java-8-code in a JAR included in a WAR although the JAR was a MRJAR with code for Java 11. That JAR included as a dependency for a regular Java SE project is running different code depending on the running JRE, but when included in a WAR, the Java-11-code seems to be ignored.

Is that expected behavior for a webserver, as Java EE 8 does not explicitly require Java 9 (which introduced MRJARs) but only Java 8? Are there other webservers that do correctly read the MRJARs when run on a newer Java version? Or are MRJARs just a feature for Java SE?

If I understand the Wildfly documentation correctly, all contents of a WAR a loaded by the same class loader (org.jboss.modules.ModuleClassLoader according to my debugger), so maybe that classloader does not correclty read the included JARs?

hd42
  • 1,741
  • 15
  • 30
  • 1
    Running with -Djdk.util.jar.enableMultiRelease=force might be useful for your testing. – Alan Bateman Nov 14 '18 at 13:39
  • 1
    That argument does not seem to have any influence on my wildfly, @AlanBateman. – hd42 Nov 14 '18 at 13:52
  • 1
    This would work for installed modules, but it doesn't look like it works for libraries in a WAR. It could have to do with the WAR not having the MR JAR spec. Feel free to file an issue at http://issues.jboss.org/browse/WFLY though. – James R. Perkins Nov 15 '18 at 03:56
  • 1
    To clarify a bit I think it has to do with libraries being loaded in the same CL as the WAR. – James R. Perkins Nov 15 '18 at 03:57
  • I opened https://issues.jboss.org/browse/WFLY-11353, @JamesR.Perkins – hd42 Nov 15 '18 at 08:03

1 Answers1

0

Well, my Bug report lead to a fix so now Wildfly does support MRJARs in deployed WARs :)

hd42
  • 1,741
  • 15
  • 30