You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Scholte (Jira)" <ji...@apache.org> on 2020/04/18 17:51:00 UTC

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

     [ https://issues.apache.org/jira/browse/MASSEMBLY-891?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Scholte closed MASSEMBLY-891.
------------------------------------
      Assignee: Robert Scholte
    Resolution: Cannot Reproduce

I've added an integration test in [940f354f3218a7866386bd4197345193ea402621|https://gitbox.apache.org/repos/asf?p=maven-assembly-plugin.git;a=commit;h=940f354f3218a7866386bd4197345193ea402621]
At this time we are testing with Java 7, 8, 11, 14 and 15-ea, the test succeeds with all versions.
See https://builds.apache.org/job/maven-box/job/maven-assembly-plugin/

Java could only be confused with the resources if they were read from the classpath, but the archiver doesn't care about that. It simply copies the bytes.

Not sure what happened, but it looks like something else (another plugin?) caused this issue.

> 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
>            Assignee: Robert Scholte
>            Priority: Major
>         Attachments: reproducer.zip
>
>
> 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
(v8.3.4#803005)