| Summary: | [quick fix] Invalid proposal to insert try/catch for unhandled exception whose type is a type parameter | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Ayushman Jain <amj87.iitr> |
| Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | deepakazad, manju656, markus.kell.r |
| Version: | 3.7 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
(In reply to comment #0) > The quick fix offers 2 invalid proposals - "surround with try/catch" and "add > catch clause to surrounding try". Both of these will cause a catch (Z z) to be > added, which is invalid since type parameters can't be caught. I am thinking of offering the quick fixes with 'Exception' instead of 'Z'. Just to be clear, I am not using the type bounds of the type parameter here i.e. I would use 'Exception' even when the type variable is defined as <Z extends IOException>. Any objections ? Spawned from bug 424616 comment 0: public class AddThrows { interface Getter2<T, E extends Exception> { T get() throws E; } public static Long main2(Getter2<Long, ?> getter) { Long value = getter == null ? 0l : 1l; /* uncomment next line, then press CTRL-1 and * select either "add throws.." or "surround.." quick fix. */ //value = getter.get(); return value; } } Both the quick fixes gives ? as the type in the catch block and throws clause which needs to be handled. (In reply to Manju Mathew from comment #2) > Spawned from bug 424616 comment 0: That's a different problem (not about throwing a type variable) and will be solved in that bug. 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. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. 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. |
Build id: I20110613-1736 public class X<T extends Exception> { public <Z extends Exception> void foo(boolean bool, Z z){ try { if (bool) throw z; // Quick fix here else throw new NullPointerException(); } catch (RuntimeException e) { } } } The quick fix offers 2 invalid proposals - "surround with try/catch" and "add catch clause to surrounding try". Both of these will cause a catch (Z z) to be added, which is invalid since type parameters can't be caught.