Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-core-dev] Compiler diagnosis for missing/unnecessary null checks



I already found a bug in it: it doesn't handle initializations in loops.



                                                                           
             Philippe P                                                    
             Mulet/France/IBM@                                             
             IBMFR                                                      To 
             Sent by:                  jdt-core-dev@xxxxxxxxxxx            
             jdt-core-dev-admi                                          cc 
             n@xxxxxxxxxxx                                                 
                                                                   Subject 
                                       [jdt-core-dev] Compiler diagnosis   
             11/25/2004 01:49          for missing/unnecessary null checks 
             PM                                                            
                                                                           
                                                                           
             Please respond to                                             
               jdt-core-dev                                                
                                                                           
                                                                           








Please double check generated diagnosis before changing the code. Some
detected instances are not obvious ones and some early bugs are still in
there.


__________________

I released an early version of compiler diagnosis for missing/unnecessary
null checks. It is not fully functional yet, but should already capture
some scenarii where local variables are misused.

Default severity is "warning", we may lower it down to "ignore" for next
integration build if testing shows it is too buggy.

e.g.
public class X {
  void foo(X x) {
    if (x == this) {
      if (x == null) {// The variable x cannot be null;
                     // it was either set to a non-null value
                     // or assumed to be non-null when last used

        x.foo(this); // The variable x can only be null;
                     // it was either set to null or checked for null
                     //when last used
      }
    }
  }
}
Not supported yet:
- complex boolean condition: if ((v == null) && v.hasMore()) { ...
- while/for conditions

Limitations:
- only works with local variables
- only perform inter-procedural static analysis (similar to variable
definite assignment rules)

_______________________________________________
jdt-core-dev mailing list
jdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-core-dev




Back to the top