Community
Participate
Working Groups
The folowing code results in an invalid warning: String s = ""; if (s != null) { System.out.println(s); } s.toString(); The if check is redundant (there's a warning), but the compiler will complain about s.toString();
Agreed
A case of second occurrence diagnostic. Agree that the given example looks odd. Still, how would you cope with the following: String s = ""; if (s != null) { // (a) System.out.println(s); } else { s.toString(); // (b) } s.toString(); // (c) Current implementation (3.2 M5) complains on a, b and c. The current bug asks that c stops complaining. What about b?
Created attachment 35413 [details] Fix with test cases Added NullReferenceTest tests # 333 to 335 (the last is not activated, see fup bug 129581 for details). The idea of the fix is to merge definite non null with protected null into a non potential null. This does not work for 335 because we only have protected non null in the then branch.
Fixed and released in HEAD.
*** Bug 129122 has been marked as a duplicate of this bug. ***
Verified for 3.2 M6 using warm-up build I20060327-0010.