Tuesday, June 26, 2007

Eclipse can detect null pointer reference

Eclipse has the ability to detect null pointer reference but it's not enable by default. To do so, go to the preferences. In the Java>Compiler>Errors/Warning page, click on "Potential programming problems". There's a "Null reference:" drop list.
You can set it to "Error", "Warning", or "Ignore".

In Eclipse 3.3 there's also a setting for "Potential null pointer access" in the same section.