Repository navigation
Conversation
sullis
force-pushed
the
ss-jspecify-edge-case
branch
from
October 7, 2026 17:43
f9f7b3b to
a9b327e
Compare
sullis
force-pushed
the
ss-jspecify-edge-case
branch
from
October 7, 2026 18:01
a9b327e to
91ca5b5
Compare
sambsnyd
approved these changes
Oct 7, 2026
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.
What's changed
New recipe
org.openrewrite.java.migrate.jspecify.RemoveAnnotationFromVoidMethod. It removes annotations matching a type pattern (for exampleorg.jetbrains.annotations.*ull*) from methods that returnvoid, wherever they appear in the declaration:@Nullable public void m()public @Nullable static void m()public static @Nullable <T> void m()public @Nullable void m()The import is removed too when nothing else uses it.
All seven JSpecify migrations in
jspecify.yml(javax, jakarta, JetBrains, Micrometer, Spring, Micronaut, FindBugs) now run this recipe beforeChangeType, and beforeMoveAnnotationToArrayTypein the migrations that use it.*ull*pattern.Nullable,CheckForNull,Nonnull; FindBugs:Nullable,CheckForNull,PossiblyNull,NonNull). In those packages*ull*also matches the*ByDefaultannotations, such as@ParametersAreNonnullByDefault, which still mean something on avoidmethod and must not be removed.Why
A nullability annotation on a
voidmethod has no meaning. JSpecify's@Nullableis aTYPE_USEannotation, so Java doesn't allow it on avoidreturn. Before this change,ChangeTypecarried code like@Nullable void foo()over to JSpecify unchanged, and the migrated code failed to compile.Scope
voidare changed. Methods returning boxedVoidkeep their annotations, sinceVoidcan legitimately benull.voidmethods are left alone.@Deprecated, stay in place.*ByDefaultannotations onvoidmethods are kept, so the existing migrations still handle them (for example, javax@ParametersAreNonnullByDefaultstill becomes@NullMarked).Tests
RemoveAnnotationFromVoidMethodTestcovers:voidmethods, parameter annotations, and boxedVoidmethods unchangedJSpecifyBestPracticesTestadds end-to-end cases for:voidmethods annotated with JetBrains and jakarta@Nullablevoidmethod with javax@Nullableand@ParametersAreNonnullByDefault:@Nullableis removed and@ParametersAreNonnullByDefaultbecomes@NullMarkedvoidmethod with FindBugs@Nullableand@ReturnValuesAreNonnullByDefault:@Nullableis removed and@ReturnValuesAreNonnullByDefaultis kept🤖 Generated with Claude Code