| Summary: | [compiler][null] wrong warning in try/catch with RuntimeException | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Görge Albrecht <eclipse> |
| Component: | Core | Assignee: | Maxime Daniel <maxime_daniel> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 3.2 | ||
| Target Milestone: | 3.2 M6 | ||
| Hardware: | PC | ||
| OS: | Windows 2000 | ||
| Whiteboard: | |||
Reproduced with build I20060321-1210. Entered (skipped) test case NullReferenceTest #561. Fixed and released in HEAD. The key for verification is to use an unchecked exception. Verified for 3.2 M6 using warm-up build I20060327-0010. Verified for 3.2M6. Mark as closed. Thanks |
In the following code the "null reference analysis" produces a false positive: 1: Object element = null; 2: try { 3: element = foo(); 4: bar(element); 5: } catch (RuntimeException e) { 6: System.out.println(element.toString()); 7: } 8: private Object foo() { 9: return ""; 10: } 11: private void bar(Object element) { 12: throw new IllegalArgumentException(""); 13: } In line 6 "element" is considered as "can only be null" but should be "may be null". If you change line 11 to 11: private void bar(Object element) throws Exception { and line 5 to 5: } catch (Exception e) { you get the correct warning.