Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 429427

Summary: [move method] NPE while moving method from anonymous class
Product: [Eclipse Project] JDT Reporter: Martin Mathew <manju656>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.4   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Martin Mathew CLA 2014-03-03 00:42:42 EST
Consider the below code snippet:
package p1;

public class C {
	B anonymous = new B() {
		@Override
		public void foo(C c) { // invoke move refactoring here
			bar(c);
		}

		private void bar(C c) {
		}
	};
}
interface B {
	void foo(C c);	
}
-------------------------------------
Invoking move method refactoring on #foo and click on OK/Preview button, NPE is thrown:

java.lang.NullPointerException
	at org.eclipse.jdt.internal.corext.dom.ASTNodeFactory.newType(ASTNodeFactory.java:135)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor$3.getTargetNode(MoveInstanceMethodProcessor.java:2577)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createArgumentList(MoveInstanceMethodProcessor.java:1710)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createMethodReference(MoveInstanceMethodProcessor.java:2562)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor$DelegateInstanceMethodCreator.createDocReference(MoveInstanceMethodProcessor.java:295)
	at org.eclipse.jdt.internal.corext.refactoring.delegates.DelegateCreator.createJavadocMemberReferenceTag(DelegateCreator.java:437)
	at org.eclipse.jdt.internal.corext.refactoring.delegates.DelegateCreator.getDelegateJavadocTag(DelegateCreator.java:422)
	at org.eclipse.jdt.internal.corext.refactoring.delegates.DelegateCreator.createJavadoc(DelegateCreator.java:345)
	at org.eclipse.jdt.internal.corext.refactoring.delegates.DelegateCreator.prepareDelegate(DelegateCreator.java:335)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createMethodDelegation(MoveInstanceMethodProcessor.java:2337)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.createChangeManager(MoveInstanceMethodProcessor.java:1829)
	at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInstanceMethodProcessor.checkFinalConditions(MoveInstanceMethodProcessor.java:1311)
	at org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring.checkFinalConditions(ProcessorBasedRefactoring.java:224)
	at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:85)
	at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:121)
	at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:209)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2333)
	at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Comment 1 Eclipse Genie CLA 2018-11-12 15:30:09 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.