Bug 184546 - [compiler][null] Spurious redundant null check warning in finally when the class has a static field
Summary: [compiler][null] Spurious redundant null check warning in finally when the cl...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-27 20:38 EDT by Markus Keller CLA
Modified: 2007-05-15 06:34 EDT (History)
0 users

See Also:
kent_johnson: review+


Attachments
Fix + test case (2.89 KB, patch)
2007-05-02 04:33 EDT, 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 Markus Keller CLA 2007-04-27 20:38:54 EDT
I20070427-0010

Spurious redundant null check warning for "var != null":
"Redundant null check: The variable var cannot be null at this location"

Very strange: If I remove the field WHY_DOES_THIS_MATTER, the wrong warning goes away.


public class Try {
	private static final char WHY_DOES_THIS_MATTER= '?';
	
	public static void main(String[]  dd ) {
		Try var= null;
		try {
			var= new Try();
			return;
		} finally {
			if (var != null) {
				System.out.println(var.hashCode());
			}
		}
	}
	
	public Try() {
		throw new IllegalStateException();
	}
}
Comment 1 Maxime Daniel CLA 2007-04-28 06:53:25 EDT
Indeed. This suggests a shift somewhere in UnconditionalFlowInfo bit fields, or a change into the variable index calculation (depending on the maximum number of fields for the class). I'll check that when I am back on Wednesday.
Comment 2 Maxime Daniel CLA 2007-05-02 04:14:55 EDT
NullReferenceTest#516 covers the case without the field.
Comment 3 Maxime Daniel CLA 2007-05-02 04:33:58 EDT
Created attachment 65572 [details]
Fix + test case

As stupid as it may sound, we never propagated maxFieldCount to NullInfoRegistry instances, creating a shift into null info. Note that this only affected try/finally statements, and null related information (not definite assignment analysis).
Comment 4 Maxime Daniel CLA 2007-05-02 04:35:36 EDT
Kent, could you please review the patch? If you're OK with it I'll release it for 3.3 RC1 (very simple, no risk, fixes a bug).
Comment 5 Maxime Daniel CLA 2007-05-11 01:47:36 EDT
Released for 3.3 RC1.
Comment 6 David Audel CLA 2007-05-15 06:34:13 EDT
Verified for 3.3RC1 using I20070515-0010