Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 350311

Summary: [1.7][quick assist] Extract multi-catch type to separate catch clause
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: markus.kell.r, satyam.kandula
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Markus Keller CLA 2011-06-24 13:45:29 EDT
BETA_JAVA7

Add a quick fix on a type in a multi-catch clause that extracts the type into a separate catch clause.

Example: Pick out NoSuchMethodException to handle it specially:

package multicatch;
import java.lang.reflect.InvocationTargetException;
public class Reflect {
	public static void main(String[] args) {
		try {
			String.class.getConstructor().newInstance();
		} catch (InstantiationException | IllegalAccessException
				| IllegalArgumentException | InvocationTargetException
				| NoSuchMethodException | SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

After this is done, it looks strange that the 'Convert to a single multi-catch block' is not available on a on a type inside a multi-catch clause. Should enable it everywhere inside the CatchClause except for the body Block.
Comment 1 Deepak Azad CLA 2011-06-24 14:01:31 EDT
Nice idea. Though we can make it more general - select one or more types and move them to a new catch block. I guess the body of the new catch block should be a copy of the current one.
Comment 2 Deepak Azad CLA 2011-07-06 22:47:32 EDT
Fix contained in patch in bug 348860 comment 11.

Fixed in BETA_JAVA7.
Comment 3 Satyam Kandula CLA 2011-07-19 11:50:52 EDT
Verified using patch 1.0.0.v20110714-1400