Bug 127244

Summary: [compiler] Null reference analysis doesn't understand assertions
Product: [Eclipse Project] JDT Reporter: Brock Janiczak <brockj>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse, max.gilead, mlists
Version: 3.2   
Target Milestone: 3.2 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Tentative implementation + test cases none

Description Brock Janiczak CLA 2006-02-10 06:11:55 EST
Version: 3.2.0
Build id: I20060208-0848

Given the following code sample, the second reference to value is flagged as a possible null reference.

public void nullTest(String value) {
	assert(value != null);
	assert(value.length() > 0);
}

I am not 100% sure this is a bug or not as assertions have to be enabled at runtime to prevent the NullPointerException, but the programmer has asserted that value should not be null at the second line.
Comment 1 Philipe Mulet CLA 2006-02-10 10:07:56 EST
Likely a good pattern to recognize in presence of assign statements.
Comment 2 Stefan Matthias Aust CLA 2006-02-15 05:15:51 EST
FYI: IDEA recognises assert statements and even offers their equivalent of "quick fixes" that will insert assert statements to get rid of those "The value might be null" warnings.
Comment 3 Maxime Daniel CLA 2006-02-17 04:46:21 EST
Created attachment 34901 [details]
Tentative implementation + test cases

See NullReferenceTest tests 950 and following.
Comment 4 Maxime Daniel CLA 2006-02-20 06:28:48 EST
Fixed and released in HEAD.
Comment 5 Maxime Daniel CLA 2006-02-22 04:05:19 EST
*** Bug 128943 has been marked as a duplicate of this bug. ***
Comment 6 Frederic Fusier CLA 2006-03-28 04:02:27 EST
Verified for 3.2 M6 using warm-up build I20060327-0010.