Bug 158000 - [compiler][null] second diagnostic absorbed within finally blocks
Summary: [compiler][null] second diagnostic absorbed within finally blocks
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.3 M3   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-20 10:54 EDT by Maxime Daniel CLA
Modified: 2006-10-30 14:10 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 Maxime Daniel CLA 2006-09-20 10:54:24 EDT
I20060918-0010
(But existed since 3.2 at least - detected in the code).
Null related warnings on a given variable within a finally block may absorb null related warnings on a second variable within the same finally block.
In the following cases, the second diagnostic is absorbed. Prepared test cases accordingly in NullReferenceTest.

public class X {
  void foo(X x) {
    x = null;
    X y = null;
    try {
    } finally {
      if (x != null) { /* */ } // 1: complains as expected
      if (y != null) { /* */ } // 2: does not complain but it should
    }
  }
}

public class X {
  void foo(Object o) {
    o = null;
    Object o2 = null;
    try { /* */ }
    finally {
      o.toString();   // 1
      o2.toString();  // 2
    }
  }
}

public class X {
 void foo(X x) {
   x = null;
   X y = null;
   try {
     x = new X();
   } finally {
     x.toString(); // 1
     y.toString(); // 2
   }
 }
}

public class X {
 void foo() {
   X x = new X();
   X y = null;
   try {
   } finally {
     if (x != null) { // 1
       x.toString();
     }
     y.toString();    // 2
   }
 }
}
Comment 1 Maxime Daniel CLA 2006-09-21 10:48:40 EDT
Will post patch once 3.3 M2 is declared (in order to avoid cumulative patch).
Had to replace a return by a continue (or nothing at all) in selected places of FinallyFlowContext#complainOnDeferredChecks. Also removed some dead code in the same method (code probably died with proposed fix for bug 149665).
Comment 2 Maxime Daniel CLA 2006-09-25 07:37:15 EDT
See patch of bug 150082.
Released for 3.3M3.
Comment 3 Olivier Thomann CLA 2006-10-30 14:10:49 EST
Verified for 3.3 M3 using warm-up build I20061030-0800