Skip to content

SONARJAVA-4121: Add nullability metadata regression coverage - #5922

Closed
francois-mora-sonarsource wants to merge 3 commits into
masterfrom
sonarjava-4121-nullability-metadata-tests
Closed

SONARJAVA-4121: Add nullability metadata regression coverage#5922
francois-mora-sonarsource wants to merge 3 commits into
masterfrom
sonarjava-4121-nullability-metadata-tests

Conversation

@francois-mora-sonarsource

Copy link
Copy Markdown
Contributor

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 @NonNull type 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 around Optional.orElse(null).

Validation

  • mvn -q -pl :java-frontend -am test

andret2344 and others added 2 commits August 7, 2026 18:00
…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.
@hashicorp-vault-sonar-prod

Copy link
Copy Markdown
Contributor

SONARJAVA-4121

@francois-mora-sonarsource
francois-mora-sonarsource marked this pull request as ready for review August 13, 2026 19:38
@sonarqube-next

Copy link
Copy Markdown

@francois-mora-sonarsource
francois-mora-sonarsource requested a review from a team August 14, 2026 07:59

@asya-vorobeva asya-vorobeva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@francois-mora-sonarsource

Copy link
Copy Markdown
Contributor Author

Closed as suggested

@gitar-bot

gitar-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds 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.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants