Skip to content

Missing "exports" statement #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adrianw3 opened this issue Mar 3, 2021 · 6 comments
Closed

Missing "exports" statement #421

adrianw3 opened this issue Mar 3, 2021 · 6 comments
Labels

Comments

@adrianw3
Copy link

adrianw3 commented Mar 3, 2021

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.

@adrianw3 adrianw3 added the bug label Mar 3, 2021
@dinomite
Copy link
Member

dinomite commented Mar 3, 2021

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?

@dinomite
Copy link
Member

dinomite commented Mar 3, 2021

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?

@cowtowncoder
Copy link
Member

Dup of #409? Note that fix would be in 2.12.2.

@adrianw3
Copy link
Author

adrianw3 commented Mar 3, 2021

@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.

@cowtowncoder
Copy link
Member

@adrianw3 I am hoping to release 2.12.2 soon.

@k163377
Copy link
Contributor

k163377 commented Apr 2, 2023

This issue is closed because 2.12.2 has already been released.

@k163377 k163377 closed this as completed Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants