You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Joachim Sauer (JIRA)" <ji...@apache.org> on 2018/07/04 14:00:00 UTC

[jira] [Created] (MASSEMBLY-891) Multi-release JAR files aren't handled correctly

Joachim Sauer created MASSEMBLY-891:
---------------------------------------

             Summary: Multi-release JAR files aren't handled correctly
                 Key: MASSEMBLY-891
                 URL: https://issues.apache.org/jira/browse/MASSEMBLY-891
             Project: Maven Assembly Plugin
          Issue Type: Bug
    Affects Versions: 3.1.0
            Reporter: Joachim Sauer


Apparently there's now a thing called a multi-release JAR where a JAR file can contain multiple copies of the same class, where some are used only on certain Java versions and up (starting with Java 9): [http://openjdk.java.net/jeps/238]

 

Sounds like a neat idea. For backwards compatibility all the "old" class files are where they always used to be and new ones are placed under META-INF/versions/<javaVersion>/

log4j-api-2.9.1.jar is such a multi-release jar and works just fine.

 

However, when building a jar-with-dependencies it seems that the "regular" class file gets overwritten with the Java 9 version of the class file for some reason.

Looking at log4j-api-2.9.1:

{{$ unzip -l log4j-api-2.9.1.jar | grep StackLocator.class}}
{{     6336 2017-09-17 22:52 org/apache/logging/log4j/util/StackLocator.class}}
{{     7264 2017-09-17 22:52 META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class}}

Looking at the jar-with-dependencies produces by maven-assembly-plugin 3.1.0:

{{unzip -l target/myproject-0.0.1-SNAPSHOT-jar-with-dependencies.jar | grep StackLocator.class}}
{{     7264 2017-09-17 22:52 org/apache/logging/log4j/util/StackLocator.class}}
{{     7264 2017-09-17 22:52 META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class}}

Now obviously the best fix would be to make maven-assembly-plugin fully Multi-release compatible and even write the correct META-INF/MANIFEST.MF Entry to make it work, but as an intermediate step even just keeping the original version as provided and not overwriting it with the Java 9 version would be an improvement.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)