RFR: [bworld] Emit lint warnings if overriding method does not have same nullability [v7]

Vicente Romero vromero at openjdk.org
Wed Feb 11 10:02:44 UTC 2026


On Tue, 10 Feb 2026 18:42:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Vicente Romero has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 30 additional commits since the last revision:
>> 
>>  - addressing review comments
>>  - addressing review comment
>>  - simplifying tests
>>  - Merge branch 'bworld' into lint.warning.for.overrides
>>  - minor change
>>  - adding support for method references
>>  - doc changes
>>  - adding support for records
>>  - Merge branch 'bworld' into lint.warning.for.overrides
>>  - minor change
>>  - ... and 20 more: https://git.openjdk.org/valhalla/compare/4b32b22f...ed545591
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4013:
> 
>> 4011:                 for (ArgsNullabilityResult incompatibleParam :
>> 4012:                         chk.checkArgsNullability(lambdaTypes, argTypes, tree.params)) {
>> 4013:                             chk.warnNullableTypes(incompatibleParam.position().vartype,
> 
> It seems like `position()` can sometimes be `null` ?
> 
> e.g.
> 
> 
> new ArgsNullabilityResult(
>                                 overridingArgs.head,
>                                 overriddenArgs.head,
>                                 overridingParams != null ? overridingParams.head : null)
> 
> 
> Surely this would cause an NPE?

in the case of lambda expressions we should always have a position because we are passing a non null value as the third argument, `tree.params`, to method Check::checkArgsNullability, but I can add a test to make sure

-------------

PR Review Comment: https://git.openjdk.org/valhalla/pull/2058#discussion_r2789648173


More information about the valhalla-dev mailing list