Bug 128546

Summary: [compiler] null reference analysis: an Object participation into a String concatenation expression should not mark it as being non null
Product: [Eclipse Project] JDT Reporter: Nils Hammar <nils.hammar>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.