You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate from Jackson 2.x to Jackson 3 (tools.jackson) (#430)
Move the codebase from com.fasterxml.jackson 2.x to tools.jackson 3.2.0.
- pom.xml: use tools.jackson.core:jackson-databind and
tools.jackson.dataformat:jackson-dataformat-xml 3.2.0; remove the
Jackson 2.x databind and dataformat-xml deps (woodstox-core retained);
bump project version 2.6.4 -> 3.0.0.
- Package/class/method renames across main and test sources:
com.fasterxml.jackson.* -> tools.jackson.*, TextNode -> StringNode,
JsonFactory -> tools.jackson.core.json.JsonFactory,
JsonProcessingException -> JacksonException,
JsonMappingException -> DatabindException, immutable mapper builders.
Behavior-preserving fixes for Jackson 3 default/API changes (no test
assertion or expected value was changed):
- MatchFunction/ReplaceFunction: guard the pattern emptiness checks so a
POJONode-wrapped RegularExpression never reaches the now-throwing
asText(); logic is identical to Jackson 2.
- ArrayUtils.compare: pass "" default to asText() so container operands
coerce to "" as they did under Jackson 2 instead of throwing.
- AgnosticTestSuite: normalize whole-number doubles with (long) d,
replicating Jackson 2's silent narrowing (Jackson 3's asLong() throws
on out-of-long-range values).
- Utils test mapper: disable FAIL_ON_TRAILING_TOKENS to restore the
Jackson 2 default so existing test inputs parse identically.
- catch (IOException) -> catch (JacksonException) where Jackson 3 methods
no longer throw checked IOException.
- README and launch scripts (tester.sh, testerui.sh, testerui.cmd):
version 2.6.4 -> 3.0.0.
Verified: mvn clean test green (1223 tests, 0 failures, 93 skipped);
mvn package builds JSONata4Java-3.0.0.jar with an OSGi Import-Package
header referencing only tools.jackson.* [3.2,4); Tester CLI evaluation
and XML round-trip smoke-tested.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-[ ]**Step 1b: Apply Jackson 3 API class/method renames (verified against the 3.2.0 jar)**
96
+
97
+
Jackson 3 renamed several `JsonNode` types and methods, not just packages. These were confirmed by inspecting `jackson-databind-3.2.0.jar` / `jackson-core-3.2.0.jar`:
98
+
99
+
-`TextNode` → `StringNode` (the class `tools.jackson.databind.node.TextNode` does not exist; `StringNode` replaces it). Affects imports, `new TextNode(...)`, `TextNode.valueOf(...)`, and `(TextNode)` casts. ~106 refs.
100
+
-`tools.jackson.core.JsonProcessingException` → `tools.jackson.core.JacksonException` (JsonProcessingException is gone from core; `JacksonException` is the unchecked base). Affects imports and `catch` clauses. ~28 refs.
101
+
-`.fieldNames()` (returned `Iterator<String>` in 2.x) → `.propertyNames()` (returns `Collection<String>` in 3.x). To preserve `Iterator`-based loops, replace `X.fieldNames()` with `X.propertyNames().iterator()`. ~21 calls.
102
+
-`.elements()` (returned `Iterator<JsonNode>` in 2.x) → `.values()` (returns `Collection<JsonNode>` in 3.x). Replace `X.elements()` with `X.values().iterator()`. ~5 calls.
103
+
-`.fields()` → `.properties()` if present. (This codebase has **0**`.fields()` calls — nothing to do, but do not introduce any.)
104
+
- NOTE: `textValue()` and `asText()`**still exist** on `JsonNode` in 3.x — do NOT rewrite those.
105
+
106
+
Apply the safe global renames with word-boundary care, then let the compiler catch the rest:
Note: `TextNode` → `StringNode` also renames the import line `import tools.jackson.databind.node.TextNode;` to `import tools.jackson.databind.node.StringNode;`, which is correct. Watch for identifiers that merely contain "TextNode" as a substring — the `\b` boundaries prevent partial-word hits, but verify at compile time.
118
+
95
119
-[ ]**Step 2: Confirm no `com.fasterxml.jackson` core/databind/xml references remain**
Expected: FAILS — errors concentrated in `Tester.java` (`getFactory().configure`, `JsonWriteFeature.mappedFeature()`) and `TesterUI.java` (`xmlMapper.enable`/`.configure`, `ToXmlGenerator.Feature`). Note each reported file:line.
126
+
Run: `mvn -q -DskipTests clean compile 2>&1 | tee /tmp/j3-compile.log | grep -E "ERROR|\.java:" | head -50`
127
+
Expected: FAILS — after Step 1b the remaining errors are concentrated in `Tester.java` (`getFactory().configure`, `JsonWriteFeature.mappedFeature()`) and `TesterUI.java` (`xmlMapper.enable`/`.configure`, `ToXmlGenerator.Feature`), plus any stragglers from the method renames. Note each reported file:line and fix iteratively.
0 commit comments