Project: JDT
Bug 80891 Move Member Type fails with anonymous inner class
Reported: 2004-12-13 19:06:47 | Status: resolved fixed

I have an abstract class (which I will attach) with a static member that is defined with an anonymous class of the same type as the enclosing class. Attempting to Refactor->Move Member Type to New File results in an error, null argument. Here is the relevant snippet. I'm trying to extract the class assigned to LastDay to a separate file. I have my cursor on the second instance of the word Relative DateRange on that line: public abstract class RelativeDateRange { public static final RelativeDateRange LastDay = new RelativeDateRange() // <- This is the inner class I want to extract to its own file. { public Date getStartTime() { Calendar cal = todayMidnight(); // back one day cal.add(Calendar.DAY_OF_YEAR, -1); return cal.getTime(); } public Date getEndTime() { Calendar cal = todayMidnight(); return cal.getTime(); } public String getValue() { return "LastDay"; } public String getLabelKey() { return "dateRange.lastDay"; } }; .... // snip } The trace from the log follows: Caused by: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: null argument; at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:105) at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:83) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring.findTypeDeclaration(MoveInnerToTopRefactoring.java:493) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring.isInstanceFieldCreationMandatory(MoveInnerToTopRefactoring.java:431) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring.checkInitialConditions(MoveInnerToTopRefactoring.java:250) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:82) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1673) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101) Root exception: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: null argument; at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:105) at org.eclipse.jdt.internal.corext.Assert.isNotNull(Assert.java:83) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring.findTypeDeclaration(MoveInnerToTopRefactoring.java:493) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring.isInstanceFieldCreationMandatory(MoveInnerToTopRefactoring.java:431) at org.eclipse.jdt.internal.corext.refactoring.structure.MoveInnerToTopRefactoring.checkInitialConditions(MoveInnerToTopRefactoring.java:250) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:82) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1673) at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:58) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)

Files changed in fix:
org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/Checks.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MemberVisibilityAdjustor.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/MoveInnerToTopRefactoring.java