| Summary: | [1.7] Quick fix to add uncaught exceptions adds already caught ones in a multi-catch block | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ayushman Jain <amj87.iitr> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | deepakazad |
| Version: | 3.8 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
This is deliberate. It is upto the user to decide what to do in this case, e.g. the user may choose to handle both exceptions separately. We can provide 'Move exception to separate catch block' quick assist as a quick fix in the produced code, see bug 352477. You can also see the reasoning in bug 350713 comment 2 for a similar scenario. |
I20110927-0800. import java.io.FileInputStream; public class E7Bug { public static void main(final String[] args) { try (FileInputStream f = new FileInputStream("")) { // Use quick fix } } } On the mentioned line above, using quick fix to "add multi-catch clause to surrounding try" results in following erreneous code. public class E7Bug { public static void main(final String[] args) { try (FileInputStream f = new FileInputStream("")) { // Use quick fix } catch (FileNotFoundException | IOException e) { // error here } } }