SONARJAVA-4121: Add nullability metadata regression coverage - #5922
SONARJAVA-4121: Add nullability metadata regression coverage#5922francois-mora-sonarsource wants to merge 3 commits into
Conversation
…notations from the method declaration Annotations inferred for a type variable at the call site were reported as annotations of the method itself, which made Optional.orElse look like it takes a @nonnull argument and never returns null.
|
asya-vorobeva
left a comment
There was a problem hiding this comment.
The rule specified (S2637) is configured in link. This is ABD domain. The changes made in this PR will not affect the rule at all, as in java-symbolic-execution we use different parser entities (java-frontend are sonar-java specific ones). So I'd suggest to cancel this PR and either implement the fix in java-symbolic-execution repository or delegate it to ABD squad.
|
Closed as suggested |
Code Review ✅ ApprovedAdds frontend regression coverage and updates parameter and return type metadata to correctly read annotations from method declarations rather than call-site type arguments. No issues found. OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |




Summary
Adds frontend regression coverage for SONARJAVA-4121's declaration-metadata boundary.
The tests ensure substituted generic types remain available while nullability metadata comes from the method declaration. They cover generic classes and methods, inherited methods, constructors, varargs, nested type-use annotations, and nullability defaults.
Why
ECJ can infer a call-site
@NonNulltype argument. That annotation must not be treated as a declaration contract of the generic method parameter or return type, which caused the S2637 false positive aroundOptional.orElse(null).Validation
mvn -q -pl :java-frontend -am test