[Checkers] Notice about Added Feature: redundant null checks

Michael Ernst mernst at csail.mit.edu
Sat Oct 18 01:08:43 EDT 2008


Mahmood-

> For the nullness demo, I decided to change my nullness example to  
> JUnit 4.4, where Assert.equals(actual, expected) throws an NPE, when  
> actual is null but expected is not.  The example is straight forward  
> and effective (I think), as junit is commonly used library.

OK, that sounds reasonable.

> Also, for the purpose of the demo, I would like to add a check for  
> redundant nullness checking.  Given an nullness test (via equality),  
> the nullness checker would report a *warning* if a nonnull value is  
> tested for nullness.

I agree that this is useful.  (FindBugs already has it, for example.)

> Unfortunately, we cannot add a warning for known- 
> to-be null tested against a NonNull reference. (i.e. String s = null;  
> if (s == "m") { .... }).

I don't quite follow.  Why can't we add that warning?

                    -Mike



More information about the checkers mailing list