Skip to content
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

Missing JsonFactory "provides" SPI with JPMS in jackson-core module #1340

Closed
rashtao opened this issue Sep 25, 2024 · 5 comments · Fixed by #1339
Closed

Missing JsonFactory "provides" SPI with JPMS in jackson-core module #1340

rashtao opened this issue Sep 25, 2024 · 5 comments · Fixed by #1339

Comments

@rashtao
Copy link

rashtao commented Sep 25, 2024

SPI does not work in Java projects using JPMS, since module-info.java does not contains any provides directive.

To reproduce, I created a Java project with:

  • module-info.java
    module foo {
        requires com.fasterxml.jackson.core;
        uses com.fasterxml.jackson.core.JsonFactory;
    }
  • main
    public static void main(String[] args) {
          Optional<JsonFactory> jf = ServiceLoader.load(JsonFactory.class).findFirst();
          System.out.println(jf.isPresent()); // --> false
    }
@rashtao rashtao changed the title SPI in JPMS SPI with JPMS Sep 25, 2024
@cowtowncoder
Copy link
Member

Interesting, I thought provides was included as format modules do that.

My main/only concern is that in this case it'd be something like

provides com.fasterxml.jackson.core.JsonFactory with
        com.fasterxml.jackson.core.JsonFactory;

which I am not sure works as expected (JsonFactory is only sub-classed by format module implementations in 2.x, basic JsonFactory implements JSON support)

@cowtowncoder
Copy link
Member

cowtowncoder commented Sep 25, 2024

@rashtao Would it be possible for you to locally build from 2.18 branch, with modified src/moditect/module-info.java to add "provides" directive, and check if that'd work? I can make PR, change, but woudl need someone to validate proposed fix.

EDIT: looks like there is #1339 already, will follow up on that.

@cowtowncoder cowtowncoder changed the title SPI with JPMS Missing JsonFactory "provides" SPI with JPMS in jackson-core module Sep 25, 2024
cowtowncoder added a commit that referenced this issue Sep 25, 2024
@rashtao
Copy link
Author

rashtao commented Sep 26, 2024

Hi @cowtowncoder ,
I have manually checked that the changes work when building from 2.18. Thanks!

@cowtowncoder
Copy link
Member

Thank you for confirming @rashtao ! I hope to release 2.18.0 by end of week.

@GedMarc
Copy link

GedMarc commented Oct 1, 2024

Unrelated to FasterXML/jackson-databind#4727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants