Community
Participate
Working Groups
Build id: I20060214-0800 I'm not sure about this one, but it seems unnecessary to give a null warning for a reference that may be null in a string concatenation. In this case, even if o is null there won't be an error at runtime because concatenating null to a string is allowed. Object o = null; System.out.println("O is: " + o);
I guess this is similar enough (first use of o is treated as 'assumed to be non-null') to be considered second test case for this bug: public class Test { public void set(Object o) { System.out.println(o + (o == null ? "" : o.toString())); }} o == null part is reported as error: "The variable o cannot be null; it was either set to a non-null value or assumed to be non-null when last used".
Sorry, after sumbitting last comment I was redirected to bug #128546 which, coincidentally, describes the issue I was describing.
*** Bug 128546 has been marked as a duplicate of this bug. ***
Changing the bug title, since the support for String concatenation was ok for String typed variables.
Created attachment 35400 [details] Fix with test cases Applies to v_643. Checked the current expression type for String into binary expressions and compound assignments, instead of doing a per local variable check. Added NullReferenceTest tests # 123, 124 and 125.
Fixed and released in HEAD.
*** Bug 132867 has been marked as a duplicate of this bug. ***
*** Bug 133335 has been marked as a duplicate of this bug. ***
Verified for 3.2 M6 using warm-up build I20060327-0010.
*** Bug 136512 has been marked as a duplicate of this bug. ***