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 269324 - "Dereferencing possible null pointer" after doing instanceof on variable (false positive)
Summary: "Dereferencing possible null pointer" after doing instanceof on variable (fal...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.2
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2016-12-13 19:28 UTC by ebakke
Modified: 2018-02-18 03:54 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description ebakke 2016-12-13 19:28:10 UTC
In the following example, the "boolean foo = k instanceof Integer" assignment causes a spurious "Dereferencing possible null pointer" warning to occur on the "k.doubleValue()" expression. This is a bit annoying, and was not the case before. Note that if the assignment to "boolean foo" is replaced by an if statement ("if (k instanceof Integer)"), the warning goes away.

public class TestClass {
  private Number getFoo() {
    return 3;

  public void testFoo() {
    Number k = getFoo();
    // The warning only occurs if this assignment is present.
    boolean foo = k instanceof Integer;
    // Warning on .doubleValue() here: "Dereferencing possible null pointer"
Comment 1 ebakke 2018-02-18 03:52:50 UTC
This bug moved to the new Apache JIRA at .
Comment 2 ebakke 2018-02-18 03:54:50 UTC
Correction: The new JIRA issue for this bug is .