Bug 177863 - [compiler][null] Spurious null pointer warning in finally block (involving def. unknown)
Summary: [compiler][null] Spurious null pointer warning in finally block (involving de...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-16 20:33 EDT by Ian Robertson CLA
Modified: 2007-04-27 10:12 EDT (History)
0 users

See Also:


Attachments
Fix + test case (9.36 KB, patch)
2007-03-23 04:02 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 Ian Robertson CLA 2007-03-16 20:33:25 EDT
If a previously null variable is set in a finally block, the compiler's null reference check remains convinced that the variable is null:

public class NullBugTest {

  public void foo() {
    Object object = null;
    try {
    }
    finally {
      object = Object.class.getClass();
      // The following line of code warns:
      //   The variable object can only be null; it was either set to null or checked for null when last used
      object.getClass();
    }
  }
}
Comment 1 Ian Robertson CLA 2007-03-16 20:34:02 EDT
This may be releated to bug 176472, but without rooting through eclipse code, it's hard to say.
Comment 2 Maxime Daniel CLA 2007-03-19 03:22:19 EDT
Released (inactive) test NullReferenceTest#532 in HEAD.
Comment 3 Maxime Daniel CLA 2007-03-23 04:02:04 EDT
FinallyFlowContext#recordUsingNullReference missed an early return on definitely unknown variables.
Comment 4 Maxime Daniel CLA 2007-03-23 04:02:35 EDT
Created attachment 61787 [details]
Fix + test case
Comment 5 Maxime Daniel CLA 2007-03-27 01:58:39 EDT
Released for 3.3 M7.
Comment 6 Olivier Thomann CLA 2007-04-27 10:12:48 EDT
Verified for 3.3M7 using I20070427-0010