Hi,
the language compatibility section states that 4.6 version is compatible with java 11 but when using it in a project with a version < 17 you get
java.lang.UnsupportedClassVersionError: org/bson/codecs/record/RecordCodecProvider has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to…)
This happens becase {{ mongodb-driver-core}} pulls bson-record-codec, and record-codec naturally requires a java 17.
[INFO] | +- org.mongodb:mongodb-driver-core:jar:4.6.0:compile [INFO] | | \- org.mongodb:bson-record-codec:jar:4.6.0:runtime
If bson-record-codec is excluded manually one get into a
java.lang.NoClassDefFoundError: org/bson/codecs/record/RecordCodecProvider` because the class is loaded while accessing MongoClientSettings.
because the codec provided (Jep395RecordCodecProvider) is instanced without reflection at MongoClientSettings
@Immutable public final class MongoClientSettings { private static final CodecRegistry DEFAULT_CODEC_REGISTRY = fromProviders(asList(new ValueCodecProvider(), new BsonValueCodecProvider(), new DBRefCodecProvider(), new DBObjectCodecProvider(), new DocumentCodecProvider(new DocumentToDBRefTransformer()), new IterableCodecProvider(new DocumentToDBRefTransformer()), new MapCodecProvider(new DocumentToDBRefTransformer()), new GeoJsonCodecProvider(), new GridFSFileCodecProvider(), new Jsr310CodecProvider(), new JsonObjectCodecProvider(), new BsonCodecProvider(), new EnumCodecProvider(), new Jep395RecordCodecProvider()));
I'm reporting this issue because I:
- couldn't find it already created
- got confused with the documentation
- for a breaking change I was expecting a major version bump.
Regards,
Juan.