Bug 129117 - [compiler][null] false positives in try/finally
Summary: [compiler][null] false positives in try/finally
Status: RESOLVED DUPLICATE of bug 128962
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-23 03:39 EST by Max Gilead CLA
Modified: 2006-03-23 08:29 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 Max Gilead CLA 2006-02-23 03:39:47 EST
I believe errors in Test and Test2 classes are detected incorrectly while, for some reason, there's no error in Test3. I don't know if it's related to bug #128547 so I'm filling a new one.

import java.io.*;
class Test {
  void foo() throws IOException {
    FileInputStream foo = null;
    FileOutputStream bar = null;
    try {
      foo = new FileInputStream("foo");
      bar = new FileOutputStream("bar");
      foo.read(); // The variable foo may be null
    } finally {
      if (foo != null) { foo.close(); }
}}}
class Test2 {
void foo2() throws IOException {
  FileInputStream foo2 = null;
  FileOutputStream bar2 = null;
  try {
    foo2 = new FileInputStream("foo");
    bar2 = new FileOutputStream("bar");
    foo2.read(); // The variable foo can only be null; it was either set to null or checked for null when last used
  } finally {
    if (foo2 != null) { return; }
}}}
class Test3 {
void foo3() throws IOException {
  FileInputStream foo3 = null;
  try {
    foo3 = new FileInputStream("foo");
    foo3.read(); // no problem
  } finally {
    if (foo3 != null) { return; }
}}}
Comment 1 Max Gilead CLA 2006-02-23 04:07:45 EST
Tested with Build id: I20060221-1300 (latest available integration/nightly)
Comment 2 Maxime Daniel CLA 2006-03-23 08:29:24 EST
This has to do with constructors that throw exceptions. See bug 128962.

*** This bug has been marked as a duplicate of 128962 ***