This post is the first in a series in which I will talk about the new features in JDT for Java 7. In this post I will focus on Multi-catch.
The new action Source > Surround With > Try/multi-catch Block allows you to surround the selected statements with a try/multi-catch block. This is also available as Surround with try/multi-catch quick fix in case there are multiple uncaught exceptions.
The new Add exceptions to existing catch clause quick fix allows you to add uncaught exceptions to an existing catch clause.
You can replace a multi-catch clause with individual catch blocks via Use separate catch blocks quick assist. The quick assist will create separate catch clauses for all the exceptions.
You can also pick out one or more selected exceptions from a multi-catch clause via Move exceptions to separate catch block.
The new Combine catch blocks quick assist allows you to combine separate catch blocks into a single multi-catch block, pretty useful for migrating existing code to Java 7. The quick assist is offered only when bodies of all the catch blocks are same, we still need to make it a little more smarter, see bug 350308. In 3.8 we will also provide this as a clean-up (bug 351179).
The compiler gives an error if an exception in a multi-catch clause is already caught by an alternative exception. The new Remove exception quick fix allows you to remove this exception.
Mark Occurrences has been updated to understand the multi-catch syntax.
There are also new Line Wrapping options in the Formatter for the multi-catch syntax.
Note: This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP.