You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which is annotated with `@Contract("null, _ -> fail")`. With that contract declaration, NullAway will understand
154
+
that the value passed as a parameter cannot be null after a successful invocation of `Assert.notNull()`.
152
155
153
156
Optionally, it is possible to set `NullAway:JSpecifyMode=true` to enable
154
157
https://github.com/uber/NullAway/wiki/JSpecify-Support[checks on the full JSpecify semantics], including annotations on
@@ -160,8 +163,8 @@ generates no warning with the recommended configuration mentioned previously in
160
163
161
164
==== Warnings suppression
162
165
163
-
There are a few valid use cases where NullAway will incorrectly detect nullability problems. In such cases, it is recommended
164
-
to suppress related warnings and to document the reason:
166
+
There are a few valid use cases where NullAway will incorrectly detect nullability problems. In such cases,
167
+
it is recommended to suppress related warnings and to document the reason:
165
168
166
169
- `@SuppressWarnings("NullAway.Init")` at field, constructor, or class level can be used to avoid unnecessary warnings
167
170
due to the lazy initialization of fields – for example, due to a class implementing
@@ -172,8 +175,8 @@ able to detect that the path involving a nullability problem will never happen.
172
175
outside of a lambda for the code path within the lambda.
173
176
- `@SuppressWarnings("NullAway") // Reflection` can be used for some reflection operations that are known to return
174
177
non-null values even if that cannot be expressed by the API.
175
-
- `@SuppressWarnings("NullAway") // Well-known map keys` can be used when `Map#get` invocations are performed with keys that are known
176
-
to be present and when non-null related values have been inserted previously.
178
+
- `@SuppressWarnings("NullAway") // Well-known map keys` can be used when `Map#get` invocations are performed with keys
179
+
that are known to be present and when non-null related values have been inserted previously.
177
180
- `@SuppressWarnings("NullAway") // Overridden method does not define nullability` can be used when the superclass does
178
181
not define nullability (typically when the superclass comes from an external dependency).
179
182
- `@SuppressWarnings("NullAway") // See https://github.com/uber/NullAway/issues/1075` can be used when NullAway is not able to detect type variable nullness in generic methods.
@@ -208,7 +211,6 @@ with JSpecify annotations.
208
211
- For method return types, instead of `@Nullable public String method()` with Spring annotations, use
209
212
`public @Nullable String method()` with JSpecify annotations.
210
213
211
-
Also, with JSpecify, you do not need to specify `@NonNull` when overriding a type usage annotated with `@Nullable` in the
212
-
super method to "undo" the nullable declaration in null-marked code. Just declare it unannotated, and the null-marked
213
-
defaults will apply (type usage is considered non-null unless explicitly annotated as nullable).
214
-
214
+
Also, with JSpecify, you do not need to specify `@NonNull` when overriding a type usage annotated with `@Nullable`
215
+
in the super method to "undo" the nullable declaration in null-marked code. Just declare it unannotated, and the
216
+
null-marked defaults will apply (type usage is considered non-null unless explicitly annotated as nullable).
0 commit comments