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 258427 - Incorrect "Dereferencing possible null pointer" hint with try-finally
Summary: Incorrect "Dereferencing possible null pointer" hint with try-finally
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-17 22:34 UTC by matthies
Modified: 2016-03-17 22:34 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 matthies 2016-03-17 22:34:08 UTC
Example code:

    public String example(String string)
    {
        if (string == null)
        {
            try
            {
                string = "foo";
            }
            finally { }
        }

        return string.trim();
    }

The hint is incorrectly shown on the trim() call. After removing the try-finally, the hint disappears. (In the original code, the try-finally was because of a lock/unlock operation.)

Maybe the hint implementation treats the finally block like a catch block and believes it would fall through if the code in the try block fails.