Bug 424616: [1.8][quick fix] Wrong throws declaration produced for
wildcard capture exception type
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExceptionAnalyzer.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExceptionAnalyzer.java
index 5f3e904..aaf1185 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExceptionAnalyzer.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ExceptionAnalyzer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -39,29 +39,29 @@
 		if (exception == null)		// Safety net for null bindings when compiling fails.
 			return true;
 
-		addException(exception);
+		addException(exception, node.getAST());
 		return true;
 	}
 
 	@Override
 	public boolean visit(MethodInvocation node) {
-		return handleExceptions((IMethodBinding)node.getName().resolveBinding());
+		return handleExceptions((IMethodBinding)node.getName().resolveBinding(), node);
 	}
 
 	@Override
 	public boolean visit(SuperMethodInvocation node) {
-		return handleExceptions((IMethodBinding)node.getName().resolveBinding());
+		return handleExceptions((IMethodBinding)node.getName().resolveBinding(), node);
 	}
 
 	@Override
 	public boolean visit(ClassInstanceCreation node) {
-		return handleExceptions(node.resolveConstructorBinding());
+		return handleExceptions(node.resolveConstructorBinding(), node);
 	}
 
-	private boolean handleExceptions(IMethodBinding binding) {
+	private boolean handleExceptions(IMethodBinding binding, ASTNode node) {
 		if (binding == null)
 			return true;
-		addExceptions(binding.getExceptionTypes());
+		addExceptions(binding.getExceptionTypes(), node.getAST());
 		return true;
 	}
 }
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/ExceptionAnalyzer.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/ExceptionAnalyzer.java
index b9c05df..a023c57 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/ExceptionAnalyzer.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/surround/ExceptionAnalyzer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -95,7 +95,7 @@
 		if (!isSelected(node) || exception == null || Bindings.isRuntimeException(exception)) // Safety net for null bindings when compiling fails.
 			return true;
 
-		addException(exception);
+		addException(exception, node.getAST());
 		return true;
 	}
 
@@ -103,35 +103,35 @@
 	public boolean visit(MethodInvocation node) {
 		if (!isSelected(node))
 			return false;
-		return handleExceptions(node.resolveMethodBinding());
+		return handleExceptions(node.resolveMethodBinding(), node);
 	}
 
 	@Override
 	public boolean visit(SuperMethodInvocation node) {
 		if (!isSelected(node))
 			return false;
-		return handleExceptions(node.resolveMethodBinding());
+		return handleExceptions(node.resolveMethodBinding(), node);
 	}
 
 	@Override
 	public boolean visit(ClassInstanceCreation node) {
 		if (!isSelected(node))
 			return false;
-		return handleExceptions(node.resolveConstructorBinding());
+		return handleExceptions(node.resolveConstructorBinding(), node);
 	}
 
 	@Override
 	public boolean visit(ConstructorInvocation node) {
 		if (!isSelected(node))
 			return false;
-		return handleExceptions(node.resolveConstructorBinding());
+		return handleExceptions(node.resolveConstructorBinding(), node);
 	}
 
 	@Override
 	public boolean visit(SuperConstructorInvocation node) {
 		if (!isSelected(node))
 			return false;
-		return handleExceptions(node.resolveConstructorBinding());
+		return handleExceptions(node.resolveConstructorBinding(), node);
 	}
 
 	@Override
@@ -141,12 +141,12 @@
 		return super.visit(node);
 	}
 
-	private boolean handleExceptions(IMethodBinding binding) {
+	private boolean handleExceptions(IMethodBinding binding, ASTNode node) {
 		if (binding == null)
 			return true;
 		ITypeBinding[] exceptions= binding.getExceptionTypes();
 		for (int i= 0; i < exceptions.length; i++) {
-			addException(exceptions[i]);
+			addException(exceptions[i], node.getAST());
 		}
 		return true;
 	}
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/AbstractExceptionAnalyzer.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/AbstractExceptionAnalyzer.java
index 322b1c3..82cb09c 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/AbstractExceptionAnalyzer.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/util/AbstractExceptionAnalyzer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,6 +15,7 @@
 import java.util.List;
 import java.util.Stack;
 
+import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTVisitor;
 import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
 import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
@@ -103,7 +104,7 @@
 		List<ITypeBinding> current= fTryStack.pop();
 		fCurrentExceptions= fTryStack.peek();
 		for (Iterator<ITypeBinding> iter= current.iterator(); iter.hasNext();) {
-			addException(iter.next());
+			addException(iter.next(), node.getAST());
 		}
 
 		// visit catch and finally
@@ -125,7 +126,7 @@
 			if (resourceTypeBinding != null) {
 				IMethodBinding methodBinding= Bindings.findMethodInHierarchy(resourceTypeBinding, "close", new ITypeBinding[0]); //$NON-NLS-1$
 				if (methodBinding != null) {
-					addExceptions(methodBinding.getExceptionTypes());
+					addExceptions(methodBinding.getExceptionTypes(), node.getAST());
 				}
 			}
 		}
@@ -133,15 +134,16 @@
 	}
 
 
-	protected void addExceptions(ITypeBinding[] exceptions) {
+	protected void addExceptions(ITypeBinding[] exceptions, AST ast) {
 		if(exceptions == null)
 			return;
 		for (int i= 0; i < exceptions.length;i++) {
-			addException(exceptions[i]);
+			addException(exceptions[i], ast);
 		}
 	}
 
-	protected void addException(ITypeBinding exception) {
+	protected void addException(ITypeBinding exception, AST ast) {
+		exception= Bindings.normalizeForDeclarationUse(exception, ast);
 		if (!fCurrentExceptions.contains(exception))
 			fCurrentExceptions.add(exception);
 	}