Version 4.6.1 and 4.7.1 not compatible with Java 11

I noticed that you experienced a similar issue like I am experiencing now, see this ticket.

You fixed this in 4.6.1 (bug occurred in 4.6.0), but I am still experiencing the issue with 4.6.0, 4.6.1 and 4.7.1. Only when I downgrade to 4.5.1 I can run our obfuscation again.

Unfortunatelly, I cannot share the code of our mongo-reader library, but the command I’m executing to reproduce the issue is: ./gradlew :libs:mongo-reader:createObfuscated

The error is:

Execution failed for task ':libs:mongo-reader:createObfuscated'.
> Can't read [/home/user/.gradle/caches/modules-2/files-2.1/org.mongodb/bson-record-codec/4.7.1/3b2bd7bc4908c4e6a19143e2f4c7ca5df8ed69cf/bson-record-codec-4.7.1.jar] (Can't process class [org/bson/codecs/record/RecordCodec$ComponentModel.class] (Unsupported version number [61.0] (maximum 57.0, Java 13)))

I’m running this with Java 11, both locally and on our CI (Github Actions) where we only install Java 11. actions/setup-java@v1, with: java-version: 11.

I hope this information helps, if you need any further details, please let me know.
I hope this is no mistake on my side, but it feels like a breaking change when upgrading from 4.5.1 to 4.6.X/4.7.X so this could actually be a bug.

Sorry to hear you are having trouble. Under normal circumstances the bson-record-codec dependency (which is the one causing this issue) will never be loaded by an application unless it is actually using Java records (which already implies Java 17), so it doesn’t cause problems for the great majority of applications.

Can you try excluding the bson-record-codec dependency from your build using Gradle dependency management features? See here for details.


1 Like

Hi Jeffrey, yes, this does the trick. Thanks for pointing out the workaround.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.