January 14, 2005

Program to find potential NPE?

After finding my second bug in production code with a NullPointerException being thrown if data is not passed into the bean, I wonder if there is a product out there that will point these out during either development or build time? IE: trying to do a .toUpperCase() on a NULL string. I am using Ant to build as well as Eclipse 3.0 to develop. Anyone know of anything? How is FindBugs with this?

Posted by doug at January 14, 2005 01:49 PM | TrackBack
Comments

Which IDE do you use? With IDEA together with InspectionGadgets, most potentially buggy scenarios would be flagged. But a general defensive strategy that works better for me is to check for null always, at every point where a pointer could be null.

Posted by: Sumit at January 14, 2005 01:56 PM

I am using Eclipse to develop, or VIM sometimes. The default for Eclipse seems to not want to warn about potential bugs, only unused variables and errors. Is there an extension/plugin that will handle this?

Posted by: doug at January 14, 2005 02:09 PM

Consider voting for it.

Add Nice Option types to Java to prevent NullPointerExceptions


Add a detector for null arguments

Posted by: Curt at January 14, 2005 06:45 PM

I'm not necessarily looking for a compile failure if there is the possibility of an NPE (although that obviously has it's advantages). I would just like a warning during coding time, or maybe even compile, that I could possibly be introducing an NPE.

Posted by: doug at January 15, 2005 05:42 PM

I have an AOP approach that uses AspectJ that I detailed in my blog entry "Implementing the Null Object Pattern using AOP"

I wouldn't call it production ready code, but it can come in handy when debugging NPE problems.

Posted by: Dale Asberry at January 18, 2005 06:28 PM

Looks like I lost the URL: http://www.artima.com/weblogs/viewpost.jsp?thread=43091

Posted by: Dale Asberry at January 18, 2005 06:30 PM
Post a comment









Remember personal info?