-
Notifications
You must be signed in to change notification settings - Fork 724
JAVASE-241 FPs when Jakarta / Javax NotNull annotation is used #5990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
aaae03c
9d1fb5a
0fb4946
f94524e
43a6fa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,11 @@ private JSymbolMetadataNullabilityHelper() { | |
| "io.reactivex.rxjava3.annotations.Nullable", | ||
| "javax.annotation.Nullable", | ||
| "jakarta.annotation.Nullable", | ||
| // Bean Validation @NotNull is a runtime constraint, not a static nullability guarantee. | ||
| // It is placed here rather than NONNULL_ANNOTATIONS because it cannot serve as a reliable | ||
| // static analysis signal (especially when groups= is used), so it is treated conservatively. | ||
| "javax.validation.constraints.NotNull", | ||
| "jakarta.validation.constraints.NotNull", | ||
|
Comment on lines
+94
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Bug: Global @NotNull move silently changes S2789/S2447/S4454 behaviorBeyond the two patched rules, the reclassification changes other rules that read nullability with no accompanying tests: S2789 (NullShouldNotBeUsedWithOptionalCheck) will now report an Avoid globally tagging @NotNull as nullable; scope the special-casing to the intended rules.: Was this helpful? React with 👍 / 👎 |
||
| "org.checkerframework.checker.nullness.compatqual.NullableDecl", | ||
| "org.checkerframework.checker.nullness.compatqual.NullableType", | ||
| "org.checkerframework.checker.nullness.qual.Nullable", | ||
|
|
@@ -119,8 +124,6 @@ private JSymbolMetadataNullabilityHelper() { | |
| "edu.umd.cs.findbugs.annotations.NonNull", | ||
| "io.reactivex.annotations.NonNull", | ||
| "io.reactivex.rxjava3.annotations.NonNull", | ||
| "javax.validation.constraints.NotNull", | ||
| "jakarta.validation.constraints.NotNull", | ||
| "lombok.NonNull", | ||
| "org.checkerframework.checker.nullness.compatqual.NonNullDecl", | ||
| "org.checkerframework.checker.nullness.compatqual.NonNullType", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving
javax/jakarta.validation.constraints.NotNullfrom NONNULL_ANNOTATIONS to WEAK_NULLABLE_ANNOTATIONS is a global change that affects every rule reading nullabilityData(), not just the two rules patched with explicit exclusions. In S6816 (NullableInjectedFieldsHaveDefaultValueCheck), getNullableAnnotation() returns present whenever an annotation exists and isNonNull() is false; a Spring@Value("${x}") @NotNullfield (a very common combination) now satisfies that condition and gets flagged "Provide a default null value for this field" — contradictory advice for a field explicitly required to be non-null. This is a new false positive introduced by the reclassification and is not covered by any test in this PR. Consider either keeping @NotNull out of both the NONNULL and NULLABLE sets (so it resolves to NO_ANNOTATION/UNKNOWN and only the intended rules change), or adding a bean-validation guard to S6816 like the ones added to S2638/S4682.Guard S6816 against Bean Validation @NotNull (mirroring the exclusion sets added to S2638/S4682).:
Was this helpful? React with 👍 / 👎