| Summary: | [compiler] definite unassignment analysis of try/catch unduly depends on the exception type | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Maxime Daniel <maxime_daniel> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | Olivier_Thomann |
| Version: | 3.4 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
Added AssignmentTest#54 (inactive) and 55. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
I20080530-1730 Eclipse rightly reports an error on the following source: public class X { public static void main(String args[]) { final int i; // def. un. try { if (false) { // def. un. i = 0; // def. as. throw new MyException() /* def. as. */; // def. un. & as. } } catch (MyException e) { /* not def. un. because not def. un. after e in every statement of the * form throw e that belongs to the try block */ i = 1; // error } } } class MyException extends Exception { } (comments follow the definition for definite assignment and definite unassignment of JLS 3 § 16). While JLS 3 § 16.2.15 does not consider exception types at all in its rules for try statements, Eclipse compiles the following *without any error*: public class X { public static void main(String args[]) { final int i; // def. un. try { if (false) { // def. un. i = 0; // def. as. throw new MyException() /* def. as. */; // def. un. & as. } } catch (Exception e) { /* not def. un. because not def. un. after e in every statement of the * form throw e that belongs to the try block */ i = 1; // missing error! } } } class MyException extends Exception { } Note: javac never complains, which implies that it does not implement the spec in that area.