47785 Exception in Extract Interface refactoring
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/in/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/in/A.java
new file mode 100644
index 0000000..9f7c410
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/in/A.java
@@ -0,0 +1,28 @@
+package p;
+
+public abstract class A {
+	public abstract void x()   ;
+	//	 TestRunListener implementation
+	public abstract void y() /* nasty */;
+	public abstract void z() // xx
+	;
+
+	/** Javadoc*/abstract public void a () /**post-Javadoc*/;
+
+	/**JD*/
+	
+	//abstract
+	
+	public abstract void b();
+	
+	//destruct
+	public
+	abstract
+	void c
+	()
+	/* Comments*/
+	/** en */
+	// gros!
+	; //post
+	public abstract void d();
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/A.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/A.java
new file mode 100644
index 0000000..e41ad30
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/A.java
@@ -0,0 +1,28 @@
+package p;
+
+public abstract class A implements I {
+	public abstract void x()   ;
+	//	 TestRunListener implementation
+	public abstract void y() /* nasty */;
+	public abstract void z() // xx
+	;
+
+	/** Javadoc*/abstract public void a () /**post-Javadoc*/;
+
+	/**JD*/
+	
+	//abstract
+	
+	public abstract void b();
+	
+	//destruct
+	public
+	abstract
+	void c
+	()
+	/* Comments*/
+	/** en */
+	// gros!
+	; //post
+	public abstract void d();
+}
diff --git a/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/I.java b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/I.java
new file mode 100644
index 0000000..c6eeed6
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/I.java
@@ -0,0 +1,20 @@
+package p;
+/** typecomment template*/
+public interface I {
+	public abstract void x();
+	//	 TestRunListener implementation
+	public abstract void y() /* nasty */;
+	public abstract void z() // xx
+	;
+	/** Javadoc*/
+	public abstract void a() /**post-Javadoc*/
+	;
+	/**JD*/
+	public abstract void b();
+	//destruct
+	public abstract void c()/* Comments*/
+	/** en */
+	// gros!
+	; //post
+	public abstract void d();
+}
\ No newline at end of file
diff --git a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
index f2efda3..d5bf4d4 100644
--- a/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
+++ b/org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
@@ -42,6 +42,10 @@
 		return new MySetup(new TestSuite(clazz));
 	}
 	
+	public static Test setUpTest(Test someTest) {
+		return new MySetup(someTest);
+	}
+
 	protected String getRefactoringPath() {
 		return REFACTORING_PATH;
 	}
@@ -682,6 +686,11 @@
 		String[][] signatures= new String[][]{};
 		validatePassingTest("C", new String[]{"A", "B", "C"}, "I", true, names, signatures, null);
 	}
+
+	public void test100() throws Exception{
+		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=47785
+		validatePassingTest("A", "I", true, false);
+	}
 	
 	public void testPaperExample0() throws Exception{
 		String[] names= new String[]{"add", "addAll", "iterator"};
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceRefactoring.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceRefactoring.java
index a50a8bd..14f16bc 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceRefactoring.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceRefactoring.java
@@ -577,7 +577,7 @@
 	private static int getMethodDeclarationLength(IMethod iMethod, MethodDeclaration methodDeclaration) throws JavaModelException{
 		int preDeclarationSourceLength= methodDeclaration.getReturnType().getStartPosition() - iMethod.getSourceRange().getOffset();
 		if (methodDeclaration.getBody() == null)
-			return methodDeclaration.getLength() - preDeclarationSourceLength;
+			return iMethod.getSourceRange().getLength() - preDeclarationSourceLength;
 		else
 			return iMethod.getSourceRange().getLength() - methodDeclaration.getBody().getLength() - preDeclarationSourceLength;
 	}