| Summary: | Fails to detect that a local variable is always initialized. | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Richard <unp1> |
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> |
| Status: | VERIFIED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Olivier_Thomann, srikanth_sankaran |
| Version: | 3.7 | ||
| Target Milestone: | 3.6.1 | ||
| Hardware: | Macintosh | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
Looks like a dup of bug 318020. Ayushman, I let you check it. If a dup, please release the fix for 318020. Thanks Olivier, this is the same as 318020. *** This bug has been marked as a duplicate of bug 318020 *** Verified for 3.7 M1 using build I20100802-1800 Verified for 3.6.1 RC2 using Build id: M20100825-0800 |
Build Identifier: I20100608-0911 The flow analysis from the compiler does not recognize that in that case public class Test { public static void main(String[] args) { Integer tmp; tmp = new Integer(5); Object o; if (tmp instanceof Integer) { o = (Integer)tmp; } else { {if (true) throw new RuntimeException();} } System.out.println(o); } } o will always be initialized when reaching the System.out.println statement. I think that this may strictly spoken not be bug as the JLS would allow to classify it as error, but previous eclipse versions compile the code without complaint. [[The actual problem occurs for me in generated code and has to be "work-arounded" each time.]] Reproducible: Always Steps to Reproduce: 1.Compiling class public class Test { public static void main(String[] args) { Integer tmp; tmp = new Integer(5); Object o; if (tmp instanceof Integer) { o = (Integer)tmp; } else { {if (true) throw new RuntimeException();} } System.out.println(o); } } in eclipse 3.6 fails with the error message "o may not be initialised", but works fine with (at least) eclipse 3.5 2. 3.