Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352465 - [1.7] Surround with try/multi-catch uses different variable names
Summary: [1.7] Surround with try/multi-catch uses different variable names
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: 3.7.1   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-19 10:31 EDT by Ayushman Jain CLA
Modified: 2011-08-03 06:15 EDT (History)
2 users (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-07-19 10:31:36 EDT
BETA_JAVA7

class Test{
public static void main(String[] args) throws IOException{
		boolean b = true;
                // selection start
		if (b)
		throw new FileNotFoundException();
		else throw new ClassNotFoundException();
		//selection end

		try {
			
		} catch (ClassNotFoundException e) {
			
		} catch (AssertionError e1) {
			
		}
}
}

Selecting from the if(b) to the throw new IOException statement and choosing Surround with> Try/multi catch gives the following output

try {
			if (b)
			throw new FileNotFoundException();
			else throw new ClassNotFoundException();
		} catch (ClassNotFoundException e2) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Notice the use of e2 in catch expression and e inside catch body.

This works fine with surround with try/catch.
Comment 1 Deepak Azad CLA 2011-07-19 10:43:33 EDT
Good catch!

Fix to go in SurroundWithTryCatchRefactoring line 282. (Replace 'varName' with 'name')
Comment 2 Deepak Azad CLA 2011-07-21 01:10:52 EDT
Fixed in BETA_JAVA7
Comment 3 Dani Megert CLA 2011-08-03 06:15:53 EDT
Verified in I20110729-1200 and M20110729-1400.