Community
Participate
Working Groups
In 3.2M5 there is a new option warning for cases where 'null' is incorrectly used, and it may fail in some cases, like in the following code: public class NullErr { public void testObj(Object obj) { System.out.println("obj="+obj); if (obj != null) { System.out.println(obj.toString()); } } } From a very strict point of view it's not very nice to access the 'obj' variable, but it is useful when debugging. The problem is that when 'obj' is joined with a string it is classified as "used" and can therefore not be null, which isn't exactly true.
Agreed, in the case of String concatenation, null is a viable value, which precludes considering obj as non null thereafter. Also, a potentially null object reference should not yield a warning in the concatenation expression itself.
*** This bug has been marked as a duplicate of 127919 ***
Verified for 3.2 M6 using warm-up build I20060327-0010.