Skip to content

Commit 563608f

Browse files
zbynektimtebeek
andauthored
Add mapping for CheckForNull to JSpecify annotation (#1179)
Co-authored-by: Tim te Beek <tim@moderne.io>
1 parent c691c9f commit 563608f

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/main/resources/META-INF/rewrite/jspecify.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ recipeList:
7171
oldFullyQualifiedTypeName: javax.annotation.Nullable
7272
newFullyQualifiedTypeName: org.jspecify.annotations.Nullable
7373
ignoreDefinition: true
74+
- org.openrewrite.java.ChangeType:
75+
oldFullyQualifiedTypeName: javax.annotation.CheckForNull
76+
newFullyQualifiedTypeName: org.jspecify.annotations.Nullable
77+
ignoreDefinition: true
7478
- org.openrewrite.java.ChangeType:
7579
oldFullyQualifiedTypeName: javax.annotation.Nonnull
7680
newFullyQualifiedTypeName: org.jspecify.annotations.NonNull

src/test/java/org/openrewrite/java/migrate/jspecify/JSpecifyBestPracticesTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void migrateFromJavaxAnnotationApiToJspecify() {
4646
"""
4747
import javax.annotation.Nonnull;
4848
import javax.annotation.Nullable;
49+
import javax.annotation.CheckForNull;
4950
5051
public class Test {
5152
@Nonnull
@@ -54,6 +55,8 @@ public class Test {
5455
public String field2;
5556
@Nullable
5657
public Foo.Bar foobar;
58+
@CheckForNull
59+
public String checked;
5760
}
5861
5962
interface Foo {
@@ -73,6 +76,8 @@ public class Test {
7376
@Nullable
7477
public String field2;
7578
public Foo.@Nullable Bar foobar;
79+
@Nullable
80+
public String checked;
7681
}
7782
7883
interface Foo {

0 commit comments

Comments
 (0)