Bug 128546 - [compiler] null reference analysis: an Object participation into a String concatenation expression should not mark it as being non null
Summary: [compiler] null reference analysis: an Object participation into a String con...
Status: VERIFIED DUPLICATE of bug 127919
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-19 10:41 EST by Nils Hammar CLA
Modified: 2006-03-28 06:08 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Hammar CLA 2006-02-19 10:41:24 EST
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.
Comment 1 Maxime Daniel CLA 2006-02-20 05:03:50 EST
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.
Comment 2 Maxime Daniel CLA 2006-02-23 06:47:15 EST

*** This bug has been marked as a duplicate of 127919 ***
Comment 3 Frederic Fusier CLA 2006-03-28 06:08:39 EST
Verified for 3.2 M6 using warm-up build I20060327-0010.