This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 244345 - False hint - possible null (ignoring equals test)
Summary: False hint - possible null (ignoring equals test)
Status: RESOLVED DUPLICATE of bug 226083
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-07 07:37 UTC by PavelCibulka
Modified: 2014-06-06 21:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description PavelCibulka 2014-05-07 07:37:11 UTC
Hints engine ignore equals method tests. Equals method return false, if argument is null. This method can be considered for possible null hint.

Example code:

    @Nonnull
    public static String test(@Nullable String value){
        if(!"test".equals(value)){
            return "something";
        }
        return value;
    }

Netbeans report possible null on "return value;". But this is not possible, because of equals test.

It is easy to understand for programmer. I'm not sure, if it would be possible to include this in hints engine.
Comment 1 Svata Dedic 2014-06-06 21:21:11 UTC

*** This bug has been marked as a duplicate of bug 226083 ***
Comment 2 Svata Dedic 2014-06-06 21:24:04 UTC
We can assume that if a.equals(b), then b != null - otherwise equals contract would be severely broken for a.