From 5a21a89cb78f021e08a002ca16a2d77b90d6d8f9 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 5 Aug 2026 09:20:18 +0200 Subject: [PATCH] Make subpackage recursion explicit in the Jackson JAX-RS JSON rename `com.fasterxml.jackson.jaxrs.json` -> `com.fasterxml.jackson.jakarta.rs.json` omits `recursive` while depending on it, so types in the `.annotation` subpackage were never migrated. Verified against the published artifacts: jackson-jaxrs-json-provider 2.14.3 -> jackson-jakarta-rs-json-provider 2.15.4 com.fasterxml.jackson.jaxrs.json.annotation -> com.fasterxml.jackson.jakarta.rs.json.annotation The subpackage maps exactly under prefix substitution, so recursion is both safe and required here. The existing tests could not catch this. `ChangePackage.recursive` is `@Nullable` with no documented default, and a null was read as non-recursive by the recipe's preconditions but as recursive by its visitor, so a subpackage type was renamed only for files that also referenced a type sitting directly in `oldPackageName`. The new test imports only `...jaxrs.json.annotation.JSONP` and fails without this change. --- .../META-INF/rewrite/jakarta-ee-9.yml | 1 + .../jakarta/JacksonJavaxtoJakartaTest.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml b/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml index e546f68007..5270ffd468 100644 --- a/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml +++ b/src/main/resources/META-INF/rewrite/jakarta-ee-9.yml @@ -1316,6 +1316,7 @@ recipeList: - org.openrewrite.java.ChangePackage: oldPackageName: com.fasterxml.jackson.jaxrs.json newPackageName: com.fasterxml.jackson.jakarta.rs.json + recursive: true - org.openrewrite.java.ChangeType: oldFullyQualifiedTypeName: com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule newFullyQualifiedTypeName: com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule diff --git a/src/test/java/org/openrewrite/java/migrate/jakarta/JacksonJavaxtoJakartaTest.java b/src/test/java/org/openrewrite/java/migrate/jakarta/JacksonJavaxtoJakartaTest.java index 17e23df977..48131e069d 100644 --- a/src/test/java/org/openrewrite/java/migrate/jakarta/JacksonJavaxtoJakartaTest.java +++ b/src/test/java/org/openrewrite/java/migrate/jakarta/JacksonJavaxtoJakartaTest.java @@ -396,4 +396,35 @@ public class A extends JacksonJsonProvider {} ) ); } + + @Test + void migrateTypeInJaxrsJsonSubpackage() { + rewriteRun( + spec -> spec.parser(JavaParser.fromJavaVersion().dependsOn( + """ + package com.fasterxml.jackson.jaxrs.json.annotation; + public @interface JSONP {} + """ + )), + //language=java + java( + """ + import com.fasterxml.jackson.jaxrs.json.annotation.JSONP; + + class A { + @JSONP + void method() {} + } + """, + """ + import com.fasterxml.jackson.jakarta.rs.json.annotation.JSONP; + + class A { + @JSONP + void method() {} + } + """ + ) + ); + } }