Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/rewrite/jakarta-ee-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,12 @@ recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule
newFullyQualifiedTypeName: com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector
newFullyQualifiedTypeName: com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
newFullyQualifiedTypeName: com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this proposed fix; Seeing the lines just above also changing classes from those same packages I wonder if it would make sense to swap out these ChangeType instances for ChangePackage. Any thoughts there? Are there classes in the old packages that we should not convert similarly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rapid response!

Good question. I did a little bit more digging, and it appears that it may not be feasible to generalize these into ChangePackage. Existing line 1052-1054 is an example (see screenshot as well): the class name has also changed.

btw, let me know if you think it would be helpful to add a few more lines to cover all the classes in the screenshot .

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the helpful screenshot! We could then still use ChangePackage to handle the cases where the class name hasn't changed, which I've applied just now. With that we're good to merge, thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
(and wow, I learned a new trick on writing recipes from you today!)


---
type: specs.openrewrite.org/v1beta/recipe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,46 @@ public class A extends JacksonXmlBindJsonProvider {}
)
);
}

@Test
void rewriteJaxbAnnotationIntrospectorToJakartaXmlBindAnnotationIntrospector() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().classpath("jackson-module-jaxb-annotations")),
//language=java
java(
"""
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;

public class A extends JaxbAnnotationIntrospector {}
""",
"""
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;

public class A extends JakartaXmlBindAnnotationIntrospector {}
"""
)
);
}

@Test
void rewriteJacksonJsonProviderToJacksonJsonProvider() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().classpath(
"jackson-databind",
"jackson-jaxrs-json-provider")),
//language=java
java(
"""
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;

public class A extends JacksonJsonProvider {}
""",
"""
import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;

public class A extends JacksonJsonProvider {}
"""
)
);
}
}