| Author |
Tool to verify null check (FindBugs, CheckStyle ..)
|
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
|
|
Dear all,
I often forget to check if an object is null before using it.
Do you know any tool (like FindBugs, CheckStyle ...) that can detect whether an object is checked before it is used and give alarm to programmer?
Thank you very much.
|
 |
Siddhesh Deodhar
Ranch Hand
Joined: Mar 05, 2009
Posts: 117
|
|
I use FindBugs. It shows me all the places where exception can come in future.
example. suppose i have a method
On this if i run findbug, it warns me at line if(cmpStr.equals("yes").
It says dont do cmpStr.equals("yes") do "yes".equals(cmpStr)
|
Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
|
 |
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
|
|
Siddhesh Deodhar wrote:I use FindBugs. It shows me all the places where exception can come in future.
example. suppose i have a method
On this if i run findbug, it warns me at line if(cmpStr.equals("yes").
It says dont do cmpStr.equals("yes") do "yes".equals(cmpStr)
Thank you very much
|
 |
Kj Reddy
Ranch Hand
Joined: Sep 20, 2003
Posts: 1697
|
|
|
I too use FindBugs, its quite useful.
|
 |
Swerrgy Smith
Ranch Hand
Joined: Mar 26, 2010
Posts: 49
|
|
I have just checked with FindBugs. It can only find simple null check. However, if we wrote something like following code:
instead of
In this case, FindBugs will not detect what we have forgotten.
Which tool can be used for this purpose?
|
 |
 |
|
|
subject: Tool to verify null check (FindBugs, CheckStyle ..)
|
|
|