Skip to content

Only add jakarta.annotation-api for JSR-250 types, not JSR-305 - #1316

Merged
timtebeek merged 1 commit into
mainfrom
tim/openrewrite-issue-1312
Oct 19, 2026
Merged

timtebeek merged 1 commit into
mainfrom
tim/openrewrite-issue-1312

Conversation

@timtebeek

@timtebeek timtebeek commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

AddCommonAnnotationsDependencies added jakarta.annotation-api:1.3.x whenever anything under javax.annotation..* was used. That also matched JSR-305 types (javax.annotation.Nullable, Nonnull, CheckForNull, javax.annotation.concurrent.*) and the JDK's javax.annotation.processing.*. None of those are in jakarta.annotation-api, so the added dependency did nothing.

onlyIfUsing takes only one type pattern, so the single AddDependency is now one entry per JSR-250 type:

  • javax.annotation.Generated, ManagedBean, PostConstruct, PreDestroy, Priority, Resource, Resources
  • javax.annotation.security.*
  • javax.annotation.sql.*

The Jakarta EE 9 AddJakartaAnnotationDependency keeps its broader pattern. Its tests expect javax.annotation.Nonnull to migrate to jakarta.annotation, which has Nonnull and Nullable since 2.1.

Tests:

  • JSR-305 @Nullable and @ThreadSafe with jsr305 on the pom: the pom is unchanged. This test fails without the fix.
  • @PostConstruct and @RolesAllowed used together: exactly one dependency is added.

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 19, 2026
@timtebeek
timtebeek merged commit e39156e into main Oct 19, 2026
2 checks passed
@timtebeek
timtebeek deleted the tim/openrewrite-issue-1312 branch October 19, 2026 15:51
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

AddCommonAnnotationsDependencies triggers on JSR-305 (@Nullable) and adds redundant jakarta.annotation-api

1 participant