RFR: [bworld] Emit lint warnings if overriding method does not have same nullability [v7]
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Feb 11 10:02:39 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().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?
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/2058#discussion_r2789625047
More information about the valhalla-dev
mailing list