Community
Participate
Working Groups
I20110927-0800. import java.io.FileInputStream; public class E7Bug { public static void main(final String[] args) { try (FileInputStream f = new FileInputStream("")) { // Use quick fix } } } On the mentioned line above, using quick fix to "add multi-catch clause to surrounding try" results in following erreneous code. public class E7Bug { public static void main(final String[] args) { try (FileInputStream f = new FileInputStream("")) { // Use quick fix } catch (FileNotFoundException | IOException e) { // error here } } }
This is deliberate. It is upto the user to decide what to do in this case, e.g. the user may choose to handle both exceptions separately. We can provide 'Move exception to separate catch block' quick assist as a quick fix in the produced code, see bug 352477.
You can also see the reasoning in bug 350713 comment 2 for a similar scenario.