Bug 127244 - [compiler] Null reference analysis doesn't understand assertions
Summary: [compiler] Null reference analysis doesn't understand assertions
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 128943 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-10 06:11 EST by Brock Janiczak CLA
Modified: 2006-03-28 04:02 EST (History)
3 users (show)

See Also:


Attachments
Tentative implementation + test cases (8.73 KB, patch)
2006-02-17 04:46 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 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.