Hi,

I'd like to ask for a review of a possible fix for NETBEANS-889
<https://issues.apache.org/jira/browse/NETBEANS-889>.

The testcase there is:
---
    String value = "";
    void nullDereference(){
        Runnable run = ()->{
            value = null;
        };
        run.run();//false positive
    }
---

The reason is that the lambda (method) is not handled as a full method, so
the changes from inside the lambda affect the outer context. The proposed
patch handles lambdas as methods.

Originally, visitMethod was filling variable2State with default values for
parameters and fields. It would be possible to extend that for lambdas, but
that seems unnecessary, as if a variable is not in the variable2State map
when used, the default is picked up automatically. See
NPECheck.VisitorImpl.visitIdent.

Proposed patch:
https://issues.apache.org/jira/secure/attachment/12927013/NETBEANS-889-2.diff

Feedback is welcome!

Thanks,
    Jan

Reply via email to