Bug 127919 - [compiler][null] non String objects references involved into string concatenation should not raise null ref. warnings
Summary: [compiler][null] non String objects references involved into string concatena...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 128546 132867 133335 136512 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-14 16:58 EST by John Arthorne CLA
Modified: 2006-04-13 07:22 EDT (History)
6 users (show)

See Also:


Attachments
Fix with test cases (14.35 KB, patch)
2006-02-27 06:30 EST, Maxime Daniel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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. ***