Project: JDT
Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
Reported: 2003-05-25 07:50:25 | Status: resolved fixed

If I have the two classes: public class A { public void method() { } } public class B extends A { public void method() throws Wobbly { } } then I (obviously) get a compile time error. However, it would be useful if the suggestion list (currently empty) could add options o Add exception to superclass implementation o Surround internally with try/catch You would then end up with (either): public class A { public void method() throws Wobbly { } } public class B extends A { public void method() throws Wobbly { } } or public class A { public void method() { } } public class B extends A { public void method() { try { } catch (Wobbly w) { // use uncaught exception code generation } } } Both would be useful options, but I'd recommend that adding an exception to the superclass' implementation is the preferred one of the two, in much the same way that the preferred unhandled exception is to declare a throws rather than a try/catch

Files changed in fix:
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ChangeMethodSignatureProposal.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java