Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360785 - [1.7] Quick fix to add uncaught exceptions adds already caught ones in a multi-catch block
Summary: [1.7] Quick fix to add uncaught exceptions adds already caught ones in a mult...
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-13 05:37 EDT by Ayushman Jain CLA
Modified: 2011-10-13 05:53 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ayushman Jain CLA 2011-10-13 05:37:26 EDT
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
      }
   }
}
Comment 1 Deepak Azad CLA 2011-10-13 05:50:42 EDT
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.
Comment 2 Deepak Azad CLA 2011-10-13 05:53:11 EDT
You can also see the reasoning in bug 350713 comment 2 for a similar scenario.