maven-shade-plugin icon indicating copy to clipboard operation
maven-shade-plugin copied to clipboard

shading failure on JDK 24

Open jakub-id opened this issue 1 year ago • 8 comments

Affected version

3.6.0

Bug description

On JDK 24 with minimizeJar=true shading errors with:

Error creating shaded jar: Unsupported class file major version 68

Bumping ASM dependency to 9.8 does not fix the problem. Please release a new version which support JDK24 and JDK25.

jakub-id avatar Sep 07 '25 09:09 jakub-id

Creating a small reproducer would be appreciated.

cstamas avatar Sep 07 '25 09:09 cstamas

stacktrace I can see

Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 68
    at org.vafer.jdeb.shaded.objectweb.asm.ClassReader.<init> (ClassReader.java:200)
    at org.vafer.jdeb.shaded.objectweb.asm.ClassReader.<init> (ClassReader.java:180)
    at org.vafer.jdeb.shaded.objectweb.asm.ClassReader.<init> (ClassReader.java:166)
    at org.vafer.jdeb.shaded.objectweb.asm.ClassReader.<init> (ClassReader.java:288)
    at org.vafer.jdependency.Clazzpath.addClazzpathUnit (Clazzpath.java:179)
    at org.vafer.jdependency.Clazzpath.addClazzpathUnit (Clazzpath.java:151)
    at org.apache.maven.plugins.shade.filter.MinijarFilter.<init> (MinijarFilter.java:104)

We only to use the new release org.vafer:jdependency:2.13

olamy avatar Sep 09 '25 05:09 olamy

done via https://github.com/apache/maven-shade-plugin/pull/749 haha so groovy has his shaded asm, jdependency has his shaded asm. someone else? :)

olamy avatar Sep 09 '25 05:09 olamy

arghh right org.vafer:jdependency:2.13 is jdk 11 minimum :(

olamy avatar Sep 09 '25 06:09 olamy

@jakub-id you can still upgrade the version in your pom in the plugin > dependencies section.

olamy avatar Sep 09 '25 06:09 olamy

I attempted to work around this in 3.6.0 by forcing the jdependency:2.13 dependency, but that alone was not enough, the update to asm:9.8 was also needed. Only with both forced dependencies I was able to compile with 24. asm-commons:9.8 isn't needed, but it'd probably be a bad idea to have a mismatch there.

Gaibhne avatar Sep 09 '25 20:09 Gaibhne

I attempted to work around this in 3.6.0 by forcing the jdependency:2.13 dependency, but that alone was not enough, the update to asm:9.8 was also needed. Only with both forced dependencies I was able to compile with 24. asm-commons:9.8 isn't needed, but it'd probably be a bad idea to have a mismatch there.

yes both are needed. asm in the plugin itself is already done via https://github.com/apache/maven-shade-plugin/pull/744 but this one we cannot really upgrade except making the plugin jdk11 required. Personnally I would not mind but this might generate some discussions

olamy avatar Sep 09 '25 21:09 olamy

You folks ping me if there is something I can do, right?

jdependency:2.14 is out for a while now.

And ASM usage in jdependency is shaded so it should be completely separate from the visitor in the shade plugin itself. Just saying.

tcurdt avatar Dec 08 '25 15:12 tcurdt

I can confirm that updating the jdependency to 2.14 fixes the same issue with Java 25 in my builds.

wilx avatar Jan 23 '26 12:01 wilx

done via #749 haha so groovy has his shaded asm, jdependency has his shaded asm. someone else? :)

As long as they are minimized - no real harm done :)

I still have this in my inbox.

Nothing I can help with I guess? Just waiting for a new release of the maven-shade-plugin? What's blocking that?

tcurdt avatar Feb 03 '26 10:02 tcurdt

done via #749 haha so groovy has his shaded asm, jdependency has his shaded asm. someone else? :)

As long as they are minimized - no real harm done :)

Yup that's not the problem :) The problem is already explained here in this comment https://github.com/apache/maven-shade-plugin/issues/747#issuecomment-3272308553

Most important part regarding jdependency

but this one we cannot really upgrade except making the plugin jdk11 required. Personnally I would not mind but this might generate some discussions

So the solution currently should be as simple as this below:

        <pluginManagement>
            <plugins>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-shade-plugin</artifactId>
                  <dependencies>
                    <dependency>
                      <groupId>org.vafer</groupId>
                      <artifactId>jdependency</artifactId>
                      <version>2.14</version>
                    </dependency>
                  </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>

olamy avatar Feb 04 '26 10:02 olamy

Well, one other option would be to re-add jdk11 support to jdependency. Cannot say I am not eager given that jdk11 is EOL for almost 3y now. But it could be an option.

But TBH. If people with that "extended commercial support/EOL" complain, we can offer them to pay for the additional work :)

tcurdt avatar Feb 04 '26 11:02 tcurdt

But TBH. If people with that "extended commercial support/EOL" complain, we can offer them to pay for the additional work :)

correct :) and btw there is easy documented workaround. I agree on jdk upgrade but this is some long debates to have on mailing list :)

olamy avatar Feb 04 '26 11:02 olamy

Fixed thanks to @tcurdt as 7edce171e15fccee898a69d264bdfdbe21229952

cstamas avatar Feb 26 '26 13:02 cstamas