Community
Participate
Working Groups
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.
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.
Fix contained in patch in bug 348860 comment 11. Fixed in BETA_JAVA7.
Verified using patch 1.0.0.v20110714-1400