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:54 UTC 2026


On Tue, 10 Feb 2026 19:38:12 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> emit a lint warning for cases like:
>> 
>> class Test {
>>     String! m(String s) { return ""; }
>> }
>> class Sub extends Test {
>>     @Override
>>     String m(String s) { return null; }
>> }
>> 
>> or:
>> 
>> class Test {
>>     String m(String! s) { return ""; }
>> }
>> class Sub extends Test {
>>     @Override
>>     String m(String s) { return null; }
>> }
>
> 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() != null ?

checking if `position()` is `null` here, I don't think this could happen but probably for erroneous lambdas? just in case we should be covered now

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

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


More information about the valhalla-dev mailing list