Missing "exports" statement
Describe the bug
I can't add the kotlin module to an ObjectMapper due to the following error: Symbol is declared in module 'com.fasterxml.jackson.kotlin' which does not export package 'com.fasterxml.jackson.module.kotlin'
Module-info has the following entries
module com.fasterxml.jackson.kotlin {
requires java.desktop;
requires kotlin.stdlib;
requires com.fasterxml.jackson.annotation;
requires com.fasterxml.jackson.databind;
provides com.fasterxml.jackson.databind.Module with com.fasterxml.jackson.module.kotlin.KotlinModule;
}
As a result, it is not possible to use the kotlin module in the way described in README.
// With Jackson 2.12 and later
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
...
val mapper = jacksonObjectMapper()
// or
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
...
val mapper = ObjectMapper().registerKotlinModule()
// or
import com.fasterxml.jackson.module.kotlin.jsonMapper
import com.fasterxml.jackson.module.kotlin.kotlinModule
...
val mapper = jsonMapper {
addModule(kotlinModule())
}
To Reproduce Create java module, and try to use one of the methods described in README to add kotlin module.
Expected behavior I should be able to use one of the methods described in README.
Versions Jackson-module-kotlin: 2.12.1 Jackson-databind: 2.12.1
Additional context It works if you use a classpath. In the case of java modules, it would throw an error because of the lack of exports. The only way to use it is to load Kotlin Module by ServiceLoader. I would strongly suggest adding necessary exports since SeviceLoader is not widely used and README is misleading.
Hmm, we are declaring com.fasterxml.jackson.module.kotlin as an export in our moditect configuration.
The massive caveat is that I haven't actually done anything with Java modules and don't have a very good understanding of it. Perhaps we're using ModiTect wrong?
The databind module, which is the owner of ObjectMapper does have an export for it. Shouldn't that be passed on to users of this module? @adrianw3 Do you have an example project?
Dup of #409? Note that fix would be in 2.12.2.
@cowtowncoder @dinomite It seems like you fixed it in 2.12.2. Adding following export statement should fix the issue
exports com.fasterxml.jackson.module.kotlin;
However, when are you going to release the changes? You released 2.12.1 on 8 January, and it broke projects which use java modules. The only possible workaround is to suppress the warning in kotlin files with this statement.
@file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
ServiceLoader is not the best mechanism to work with if you got many implementations of the one interface.
@adrianw3 I am hoping to release 2.12.2 soon.
This issue is closed because 2.12.2 has already been released.