JAVA-4789: Make bson.record.codec module optional for OSGi #1024
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the Java Driver can't be used in OSGi containers using a Java version lower than 17, which according to the compatibility matrix should not happen, as it should be compatible from Java 8+.
The problem is that there is a dependency of bson.codecs.record, which requires Java17+ according to its MANIFEST.MF:
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))"
This change will make the Import-Package attribute for bson.codecs.record optional, meaning when trying to use it in a OSGi container it won't fail because the dependency can't be satisfied in lower versions than 17.
After building with this change applied, that line in the MANIFEST.MF file will look like this:
org.bson.codecs.record;resolution:=optional;version="[4.7,5)"
We can see above this line that the same approach is used for jdk.net.
This change will still require Java 17+ to build the driver, but allows its use in OSGi containers using lower versions.
JAVA-4789