I have this little piece of code here, which always will throw a NPE:
public class Test1 {
private final static Object OBJECT = new Object() {{
System.out.println("OBJECT.toString() = " + OBJECT.toString());
}};
public static void main(String[] args) { }
}
Are there ways though that OBJECT
can be initialized in the instance initialization block? Or will every possible reference to OBJECT
in the instance initialization block always throw a NPE?
For those Fastest-Gun-In-The-Wests, read this: No, I am not asking you to solve my bug. This is a simplified piece of code I've seen somewhere and which to my surprise does not give a null warning in either Eclipse or Netbeans, which I would expect it to give.