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

Vicente Romero vromero at openjdk.org
Mon Feb 9 21:51:55 UTC 2026


On Mon, 9 Feb 2026 16:02:27 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Vicente Romero has updated the pull request incrementally with 20 additional commits since the last revision:
>> 
>>  - minor change
>>  - minor change
>>  - removing commented code
>>  - addressing review comments
>>  - minor code change
>>  - adding separate compilation test
>>  - updating tests
>>  - another update
>>  - reducing common code
>>  - adding support for explicit lambdas
>>  - ... and 10 more: https://git.openjdk.org/valhalla/compare/4c1b385b...fd10017d
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 1975:
> 
>> 1973:     }
>> 1974: 
>> 1975:     public void checkArgsNullability(List<Type> overridingArgs,
> 
> One possibility to simplify this w/o passing a lot lambdas could be to just have a method that returns a Pair of incompatible types -- then the client will do what it want with it; or `null` if there's no incompatibility

I have uploaded another iteration that does this, thanks!

> src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties line 4401:
> 
>> 4399: # 0: type, 1: type
>> 4400: compiler.misc.return.type.nullability.mismatch=\
>> 4401:     return type {0} in the overriding does not match the return type {1}! in the overridden method
> 
> You shouldn't need the `!` here -- if the type has restrictions, they should be displayed

if I remove this from the message then the `!` is not issued

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

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


More information about the valhalla-dev mailing list