| Summary: | [surround with try/catch][quick fix] Multi-Catch QuickFix creates compiler error | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Thomas Schindl <tom.schindl> | ||||||||
| Component: | UI | Assignee: | Samrat Dhillon <samrat.dhillon> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | daniel_megert, gabor.liptak, manju656, markus.kell.r, samrat.dhillon | ||||||||
| Version: | 4.2 | Keywords: | helpwanted | ||||||||
| Target Milestone: | 4.4 M3 | Flags: | manju656:
review-
|
||||||||
| Hardware: | All | ||||||||||
| OS: | All | ||||||||||
| Whiteboard: | |||||||||||
| Bug Depends on: | |||||||||||
| Bug Blocks: | 478714, 478715 | ||||||||||
| Attachments: |
|
||||||||||
Bug 348860 was about adding a quick fix to remove redundant catch clauses. This bug is about a bug in the implementation of the surround with try-catch quick fix. Created attachment 221222 [details]
patch for this bug
Proposing a patch for this defect. The intention of the modification is to filter down the list of exceptions so that if a super class of an exception is already present in the list, then the super class is used in the catch block and the subclass is removed from the list.
Note that a similar fix is required for "Add exception to existing catch clause" proposal/quick fix.
Created attachment 236463 [details] test for the patch Adding tests for the patch submitted earlier. This contribution complies with http://www.eclipse.org/legal/CoO.php The provided fix is too complicated. I have accepted the testcases. Fixed "Add exception to existing catch clause" also. Have a look at the released fix. Released the fix as: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=794af31895de019e6dee502e0d1f0ba337c03cdd Released the tests as: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=40af1211b9a2b7e7e9a8c6da73ab7be6b24f07a3 This is still an issue with Eclipse 4.5.0. See the attached video. Please reopen the ticket. Created attachment 256663 [details]
A video, which shows, that the bug still exists in Eclipse Mars.
Sorry, the attachment is an mp4. I made a mistake during renaming it. (In reply to Gábor Lipták from comment #5) > This is still an issue with Eclipse 4.5.0. See the attached video. Please > reopen the ticket. For better bookkeeping please file a new bug that depends on this one. Thanks. (In reply to Dani Megert from comment #8) > (In reply to Gábor Lipták from comment #5) > > This is still an issue with Eclipse 4.5.0. See the attached video. Please > > reopen the ticket. > > For better bookkeeping please file a new bug that depends on this one. > Thanks. Created Bug 478715. |
This somehow looks like #348860 which should be fixed since a long time but I see this on 4.2.0 ----8<---- package test; import java.io.IOException; import java.net.MalformedURLException; public class TestException { private static void call() throws MalformedURLException, IOException { } public static void main(String[] args) { call(); } } ----8<---- when executing the multi-catch quickfix it creates code like this: ----8<---- package test; import java.io.IOException; import java.net.MalformedURLException; public class TestException { private static void call() throws MalformedURLException, IOException { } public static void main(String[] args) { try { call(); } catch (MalformedURLException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } ----8<----