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 224988 - Null Pointer Dereference for @Nullable fields when field processing is disabled
Summary: Null Pointer Dereference for @Nullable fields when field processing is disabled
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Linux
: P2 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks: 222795
  Show dependency tree
 
Reported: 2013-01-16 19:08 UTC by Jan Lahoda
Modified: 2013-01-23 12:58 UTC (History)
1 user (show)

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 Jan Lahoda 2013-01-16 19:08:01 UTC
Trunk build 201301120001.

An incorrect possible null dereference is reported for this code when field processing is disabled:
class Test {

     @Nullable
     private String str;

     public void test() {
          assert (str != null);
          System.err.println(str.length()); //Possible null dereference
     }

     @interface Nullable {
     }
}

The reason is that the status is read for the field from the annotations even if the field processing is disabled (if the field processing would be enabled, it would find out that "str" cannot be null). If "str.length()" is replaced with "this.str.length()", the warning does not appear as the state is not read from the annotations on that code path.
Comment 1 Jan Lahoda 2013-01-16 22:38:47 UTC
Fixed:
http://hg.netbeans.org/jet-main/rev/3ddeec92da07
Comment 2 Jiri Prox 2013-01-17 13:42:59 UTC
verified in trunk
Comment 3 Dusan Balek 2013-01-17 14:02:37 UTC
The fix seems to be OK.
Comment 4 Quality Engineering 2013-01-18 02:50:41 UTC
Integrated into 'main-golden', will be available in build *201301180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3ddeec92da07
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #224988: [NPECheck] when field analysis in disabled, must not read the fields' annotations in visitIdentifier
Comment 5 Jan Lahoda 2013-01-18 08:16:18 UTC
release73:
http://hg.netbeans.org/releases/rev/c23b4881f44e
Comment 6 Quality Engineering 2013-01-19 00:03:29 UTC
Integrated into 'releases', will be available in build *201301182100* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/c23b4881f44e
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #224988: [NPECheck] when field analysis in disabled, must not read the fields' annotations in visitIdentifier
Comment 7 Jiri Prox 2013-01-23 12:58:03 UTC
verified