Bug 132867 - [compiler] nullreference analysis after string concatenation
Summary: [compiler] nullreference analysis after string concatenation
Status: RESOLVED 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: ---   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-22 12:08 EST by Michael Bartmann CLA
Modified: 2006-03-24 04:00 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 Michael Bartmann CLA 2006-03-22 12:08:09 EST
<sniplet>
LOG.error("Can't log eventData: " + eventData, ex); //$NON-NLS-1$
                                //  ^^^^^^^^^ if this is commented out, there is no subsequent warning

if (eventData != null)  // WARNING: The variable eventData cannot be null.....
{
  /** log eventData to logger */
  PDWLogger.PWD_FAILED_LOG.info(eventData);
}
</sniplet>

It seems the compiler assumes string concatenation as a pointer dereference,
but string concatenation accepts null values and prints "(null)" w/o any
NullPointerException, so the subsequent check is reachable with a null value,
and the check is ok and should not get warned.
Comment 1 Michael Bartmann CLA 2006-03-23 06:58:53 EST
String concatenation of null values is detected as a false posive, too.

Object x = null;
System.out.println( "x=" + x );  // Warning

In this case it is often desired behaviour to get the output

x=(null)

Comment 2 Maxime Daniel CLA 2006-03-24 04:00:54 EST
Added NullReferenceTest #126-127.

*** This bug has been marked as a duplicate of 127919 ***