Skip to content

The Jakarta annotation migration adds jakarta.annotation-api for imports the parser could not resolve - #1265

Merged
jkschneider merged 1 commit into
jakarta/jaxb-api-for-importsfrom
jakarta/annotation-api-for-imports
Oct 4, 2026
Merged

jkschneider merged 1 commit into
jakarta/jaxb-api-for-importsfrom
jakarta/annotation-api-for-imports

Conversation

@jkschneider

Copy link
Copy Markdown
Member

Java 8 also ships javax.annotation.Resource and the other Common Annotations, so Java 8 LSTs leave them unresolved too, and JavaxAnnotationMigrationToJakartaAnnotation moved @Resource to jakarta.annotation.Resource without adding jakarta.annotation-api. It now runs AddApiDependencyForImports, the #1257 recipe as generalized in the previous pull request, for jakarta.annotation and 2.0.x. Imports from javax.annotation.processing, which is still in the JDK, and javax.annotation.concurrent, which comes from JSR-305, do not count, the same packages the migration's non-recursive ChangePackage already leaves alone.

Found by a team of coding agents reviewing a Moderne run of org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta over the 31 Arquillian repositories (run 20261003120559-YQoma). The issue is annotation-api-missing-java8 in the run's io.moderne.RecipeIssues data table (1 row), and the fix was discussed and reviewed on the run's message board. A row from the table, as a generalized example:

Java 8 Resource annotations are migrated without adding their Jakarta API. (arquillian/arquillian-rusheye, rusheye-api/pom.xml, recipe org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta)

Before:

No annotation dependency; class A { @javax.annotation.Resource Object value; }

What the recipe produced:

No annotation dependency; class A { @jakarta.annotation.Resource Object value; }

Expected:

jakarta.annotation:jakarta.annotation-api:2.0.0; class A { @jakarta.annotation.Resource Object value; }

Stacked on #1264 (2 of 19); merge that one first.

@jkschneider
jkschneider force-pushed the jakarta/annotation-api-for-imports branch from 621cf89 to ab6da14 Compare October 3, 2026 22:26
@jkschneider
jkschneider added this pull request to stack #1284 October 4, 2026 09:43
@jkschneider
jkschneider merged commit 5802665 into main Oct 4, 2026
1 check passed
@jkschneider
jkschneider deleted the jakarta/annotation-api-for-imports branch October 4, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant