Bug 127919

Summary: [compiler][null] non String objects references involved into string concatenation should not raise null ref. warnings
Product: [Eclipse Project] JDT Reporter: John Arthorne <john.arthorne>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse, max.gilead, michael.bartmann, nils.hammar, ricky_clarkson, tacpub
Version: 3.2   
Target Milestone: 3.2 M6   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Fix with test cases none

Description John Arthorne CLA 2006-02-14 16:58:37 EST
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);
Comment 1 Max Gilead CLA 2006-02-23 06:19:32 EST
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".
Comment 2 Max Gilead CLA 2006-02-23 06:25:37 EST
Sorry, after sumbitting last comment I was redirected to bug #128546 which, coincidentally, describes the issue I was describing.
Comment 3 Maxime Daniel CLA 2006-02-23 06:47:15 EST
*** Bug 128546 has been marked as a duplicate of this bug. ***
Comment 4 Maxime Daniel CLA 2006-02-27 06:25:40 EST
Changing the bug title, since the support for String concatenation was ok for String typed variables.
Comment 5 Maxime Daniel CLA 2006-02-27 06:30:32 EST
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.
Comment 6 Maxime Daniel CLA 2006-02-27 07:13:36 EST
Fixed and released in HEAD.
Comment 7 Maxime Daniel CLA 2006-03-24 04:00:54 EST
*** Bug 132867 has been marked as a duplicate of this bug. ***
Comment 8 Maxime Daniel CLA 2006-03-27 08:38:00 EST
*** Bug 133335 has been marked as a duplicate of this bug. ***
Comment 9 Frederic Fusier CLA 2006-03-28 06:07:04 EST
Verified for 3.2 M6 using warm-up build I20060327-0010.
Comment 10 Maxime Daniel CLA 2006-04-13 07:22:22 EDT
*** Bug 136512 has been marked as a duplicate of this bug. ***