Skip to content

Support more nullability return annotations#945

Draft
xujunfeng1 wants to merge 1 commit into
openrewrite:mainfrom
xujunfeng1:agent/nullability-annotations-return-type
Draft

Support more nullability return annotations#945
xujunfeng1 wants to merge 1 commit into
openrewrite:mainfrom
xujunfeng1:agent/nullability-annotations-return-type

Conversation

@xujunfeng1

@xujunfeng1 xujunfeng1 commented Jul 21, 2026

Copy link
Copy Markdown

What changed

  • Recognize method-level nullability annotations by simple annotation name in NullableOnMethodReturnType.
  • Move CheckForNull, NonNull, Nonnull, and NotNull annotations to the return type, alongside existing Nullable handling.
  • Added coverage for javax.annotation.CheckForNull and org.jetbrains.annotations.NotNull.

Why

  • Fixes NullableOnMethodReturnType seems incomplete #318. The recipe previously only matched annotations ending in Nullable, so common nullability annotations such as CheckForNull and NotNull were left on the method declaration instead of being moved to the return type.

Validation

  • Attempted ./gradlew.bat --version, but the Gradle wrapper could not download gradle-9.5.1-bin.zip from downloads.gradle.org in this environment: java.net.SocketTimeoutException: Connect timed out.
  • Targeted tests were added in NullableOnMethodReturnTypeTest, but could not be executed locally until the Gradle distribution is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

NullableOnMethodReturnType seems incomplete

2 participants