jackson-core: jackson-core:2.15.0-rc1 causes Gradle (pre-7.6) build failure

When com.fasterxml.jackson.core:jackson-core:2.15.0-rc1 is in the buildscript dependencies it fails to write locks.

Expected Behavior

Build should succeed

Current Behavior

Build fails with the error

./gradlew build                                                                                                                                                             

 FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'project'.
> java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to create Jar file /Users/<redacted>/.gradle/caches/jars-9/c94f549fdaad0dab4fb786ae7d97e150/jackson-core-2.15.0-rc1.jar.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 569ms

Steps to Reproduce

Clone this repo and run ./gradlew build

Additional notes:

  • Version 2.15.0-rc1 of jackson-core introduces a multi-release jar [link to release notes], which is likely the reason why this error occurs on this particular version and not earlier versions.
  • This bug does not reproduce in Gradle version 7.6.1
  • I’m not sure whether this is an issue with jackson-core or with Gradle, so I opened an issue with Gradle too: https://github.com/gradle/gradle/issues/24390

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 20 (15 by maintainers)

Commits related to this issue

Most upvoted comments

So far, it looks like old versions of Gradle use an old version of asm and tries to analyse META-INF/versions classes that it shouldn’t. It seems newer versions of Gradle have fixed the issue. Please use newer versions of Gradle (7.6.1 and 8.0.2 do not hit the issue in the sample).

Resolution: if affected, upgrade to Gradle 7.6.1 or later. As per comment https://github.com/gradle/gradle/issues/24390#issuecomment-1480002416 should NOT affect basic dependency resolution.

Closing.

The issue is that Gradle’s asm jar needs to be upgraded every time there is a new Java release. I wish they would be able to code defensively around ignoring META-INF/version/X classes that are too new for their asm jar.

This is a bug in Gradle - gradle/gradle#24390

  • Why Gradle team are running asm and looking at every class file in the jar is beyond me.
  • multi-release jars have been around since Java 9 - why Gradle doesn’t just ignore classes in the META-INF/versions that are for versions higher than the Java runtime being used - this is very strange - Java runtime itself does this
  • not being robust around asm jar versions is a major issue for Gradle - new Java versions come out every 6 months and the Gradle team need to learn to skip over the classes in META-INF/versions that asm can’t handle

If the Jackson team are to worry about old versions of Gradle, I really don’t know where to go.

  • possibly best to abandon fastdoubleparser support altogether - it probably isn’t widely used
  • it might be possible to hack the maven-shade-plugin usage in jackson-core to strip out the META-INF/versions/19 files - these are the most likely to be leading to this issue - this would need testing
  • go further with the maven-shade-plugin usage in jackson-core and strip out all files in META-INF/versions and this would need testing

I don’t know if Gradle team will look at gradle/gradle#24390 - it’s possible that they will backport the Gradle 7.6 fix - but I suspect it is unlikely.

I must admit to being reluctant to volunteer time on this. I feel strongly that this is a bug in Gradle and one that has been fixed to boot.

upgrading Gradle does eliminate the issue, but my project is constrained and cannot upgrade the Gradle version

So don’t upgrade jackson then. There is no real constraint not to update - just some management issue that is not my concern.