Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
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
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java
String expected2= buf.toString();
		
		proposal= (CUCorrectionProposal) proposals.get(2);
		String preview3= getPreviewContent(proposal);
		buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("public class E {\n");
		buf.append("    public void foo(Thread o) {\n");
		buf.append("        Thread th= o;\n");
		buf.append("    }\n");
		buf.append("}\n");
		String expected3= buf.toString();
		
		assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 });		
	}
	
	public void testTypeMismatchInVarDecl2() throws Exception {
		IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
		StringBuffer buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.util.List;\n");		
		buf.append("public class Container {\n");
		buf.append("    public List[] getLists() {\n");
		buf.append("        return null;\n");
		buf.append("    }\n");
		buf.append("}\n");
		pack1.createCompilationUnit("Container.java", buf.toString(), false, null);
		buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.util.ArrayList;\n");