| Summary: | [1.7][compiler] Missing error in multi catch scenario | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | amj87.iitr, Olivier_Thomann | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
These are not for immediate action. But we need to get the spec clarified and also track javac changes. (In reply to comment #1) > These are not for immediate action. But we need to > get the spec clarified and also track javac changes. Nothing has changes as of 7b135. (In reply to comment #0) > (1) Reading the latest version of spec, it would appear > that the following program should not compile: [...] > The multi catch types must be disjunctive and the order should not matter. > (c.f the section on normalization) However javac 7b131 compiles this as > does eclipse. This code is rejected by javac 7b138. So this item is not a gray area anymore. Our reading of the spec is matched by javac. > (2) Perusing some of the associated material, it looks like: [...] > should not compile. Again it compiles with 7b131 and in eclipse. In the > latter it generates a warning about unreachable catch block. This code elicits a new warning about unreachable catch block from javac 7b138. Eclipse already emits this warning, so we are good. Created attachment 195320 [details]
Patch under test
Released in BETA_JAVA7 branch. For comment 0 (2), do we need to emit the warning also in source 1.6 ? Looks good. Verified. (In reply to comment #6) > For comment 0 (2), do we need to emit the warning also in source 1.6 ? We already do that (even on HEAD). |
(1) Reading the latest version of spec, it would appear that the following program should not compile: import java.io.FileNotFoundException; import java.io.IOException; public class X { public static void main(String [] args) { try { throw new FileNotFoundException(); } catch(FileNotFoundException | IOException e) { } } } The multi catch types must be disjunctive and the order should not matter. (c.f the section on normalization) However javac 7b131 compiles this as does eclipse. (2) Perusing some of the associated material, it looks like: import java.io.IOException; import java.io.FileNotFoundException; public class X { public static void main(String [] args) { try { throw new FileNotFoundException(); } catch (FileNotFoundException ex) { } catch (IOException ex) { } } } should not compile. Again it compiles with 7b131 and in eclipse. In the latter it generates a warning about unreachable catch block.