Skip to content

Pluggable JSON codecs: support Jackson 2 and Jackson 3 - #224

Draft
andreaTP wants to merge 2 commits into
roastedroot:mainfrom
andreaTP:json-codecs
Draft

andreaTP wants to merge 2 commits into
roastedroot:mainfrom
andreaTP:json-codecs

Conversation

@andreaTP

@andreaTP andreaTP commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #223.

Core is renamed quickjs4j-core and no longer depends on Jackson: values go through a JsonCodec, set with Engine.Builder.withJsonCodec or the generated proxy builders, or else created by the highest priority JsonCodecProvider found with ServiceLoader.

Artifact Contents
quickjs4j-core Engine, JsonCodec and JsonCodecProvider, no JSON library
quickjs4j-jackson2 Jackson 2 codec
quickjs4j-jackson3 Jackson 3 codec, preferred when both are on the classpath
quickjs4j no code: core and the default codec, Jackson 2 for now

Existing users keep quickjs4j and the same behaviour. Moving the default to Jackson 3 later is a one-line change in quickjs4j.

Generated proxies get a builder, Calculator_Proxy.builder(script, ctx).withJsonCodec(codec).build(), so libraries such as the Quarkus extension can pass a codec explicitly (for example wrapping the application's ObjectMapper) instead of relying on the classpath.

Engine.DEFAULT_OBJECT_MAPPER is removed, and withObjectMapper(mapper) becomes withJsonCodec(Jackson2Codec.builder().withObjectMapper(mapper).build()).

The first commit moves the build to Java 17, which Jackson 3 needs; it can go in as its own PR.

@hrgdavor

Copy link
Copy Markdown
Contributor

just checking in, any timeline for this ? I hope I will be quick wth sourcemap continuation after this :)

@andreaTP

Copy link
Copy Markdown
Collaborator Author

@hrgdavor I haven't had time to properly review this one and I think I want to iterate a little more on this.
I was waiting for user's requests but looks like the most used versions of frameworks are still on Jackson 2, so we probably have some time.

I hope I will be quick wth sourcemap continuation after this :)

I don't see a blocker here, I'm still waiting for a strawman/prototype, I'd encourage you to go ahead(starting from whatever branch) and submit a draft PR, it's easy to deal with rebases those days and I'd be happy to help.

@hrgdavor

Copy link
Copy Markdown
Contributor

ok, I will checkout this branch and base the impl on it, I can install a version locally, this way I might help by using the changed code if I stumble upon any issues.

Jackson 3 needs Java 17, as do the current Quarkus, Spring Boot and
Camel releases.

CI runs on JDK 17 and 21. Checkstyle and google-java-format run on
JDK 21 only, since they need it.
@andreaTP
andreaTP force-pushed the json-codecs branch 4 times, most recently from e18c229 to e9d9970 Compare November 24, 2026 12:21
Core is renamed quickjs4j-core and no longer depends on Jackson. It maps values through a JsonCodec: the one set with Engine.Builder.withJsonCodec or the new builder of the generated proxies, or else the one created by the highest priority JsonCodecProvider found with ServiceLoader.

- quickjs4j-jackson2 and quickjs4j-jackson3: the codecs, built with Jackson2Codec.builder() and Jackson3Codec.builder(). Jackson 3 is preferred when both are present.
- quickjs4j: no code, it depends on core and the default codec, Jackson 2 for now, so existing users keep the same behaviour. The default can later move to Jackson 3 with a dependency change.

The codec jars ship GraalVM metadata, so they are also found in native images built with the ServiceLoader feature disabled, as Quarkus does.

Engine.DEFAULT_OBJECT_MAPPER is removed, and withObjectMapper(mapper) becomes withJsonCodec(Jackson2Codec.builder().withObjectMapper(mapper).build()).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forcing jackson dependency in core

2 participants