Community
Participate
Working Groups
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; } }}}
Tested with Build id: I20060221-1300 (latest available integration/nightly)
This has to do with constructors that throw exceptions. See bug 128962. *** This bug has been marked as a duplicate of 128962 ***