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 246566 - Final object referenced by in a instance initialization block always throw a NPE
Summary: Final object referenced by in a instance initialization block always throw a NPE
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.1
Hardware: PC Windows 8 x64
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-20 07:13 UTC by skiwi
Modified: 2015-04-07 13:22 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description skiwi 2014-08-20 07:13:23 UTC
When having the following code:

public class Bug1 {
    private final static Object OBJECT = new Object() {{
        System.out.println("OBJECT.toString() = " + OBJECT.toString());
    }};
    public static void main(String[] args) { }
}

It will always generate a NPE, because I am referencing OBJECT before it is created. Yet the IDE does not show a warning (or even error) that I am dereferencing a null-pointer.

I think this is a bug, because I think it will always give a NPE.