The Jakarta JAXB migration adds jakarta.xml.bind-api for imports the parser could not resolve - #1264
Merged
Merged
Conversation
…er could not resolve Generalize AddJaxbApiForImports into AddApiDependencyForImports (package and coordinates as options), skip modules that declare the API through a provided dependency, and use it in the Jakarta JAXB migration.
jkschneider
force-pushed
the
jakarta/jaxb-api-for-imports
branch
from
October 3, 2026 22:26
98d7c83 to
b430e31
Compare
jkschneider
added this pull request to stack #1284
October 4, 2026 09:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Java 8 project gets JAXB from the JDK, so its LST holds unresolved
javax.xml.bindtypes, andJavaxXmlBindMigrationToJakartaXmlBind, whoseAddDependencyrelies ononlyIfUsing: javax.xml.bind..*, moved the imports tojakarta.xml.bindwithout addingjakarta.xml.bind-api, so the module no longer compiled. #1257 closed the same gap for the Java 11+ migrations withAddJaxbApiForImports, which matches imports by name, but that recipe is fixed tojavax.xml.bindand version 2.3.x and the Jakarta migration does not run it. Rather than add a second recipe that does the same thing, this generalizes it:AddJaxbApiForImportsbecomesAddApiDependencyForImportswith the package and the dependency coordinates as options (ajakartapackage also matches imports of itsjavaxpredecessor),AddJaxbAPIDependenciesconfigures it forjavax.xml.bindand 2.3.x as before, andJavaxXmlBindMigrationToJakartaXmlBindnow runs it forjakarta.xml.bindand 3.0.x. The one behavior added to #1257's recipe is that a module declaring the API, or a dependency that carries it, inprovidedscope is left alone. That check reads the declared scope, because Maven's provided resolution scope also lists compile and runtime dependencies, so an API reached only through a runtimejaxb-runtimestill gets a compile declaration.AddJaxbApiForImportshas not been released yet, so its recipe name goes away without a replacement, and like #1257 this covers Maven builds only.Found by a team of coding agents reviewing a Moderne run of
org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakartaover the 31 Arquillian repositories (run 20261003120559-YQoma). The issue isjaxb-api-missing-java8in the run'sio.moderne.RecipeIssuesdata table (6 rows), and the fix was discussed and reviewed on the run's message board. A row from the table, as a generalized example:JAXB annotations supplied by Java 8 are migrated without adding the Jakarta JAXB compile dependency. (
arquillian/arquillian-recorder,arquillian-recorder-reporter/arquillian-recorder-reporter-spi/pom.xml, recipeorg.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta)Before:
What the recipe produced:
Expected:
First of a stack of 19 pull requests from the same review; each later one is based on the one before it.