Project: JDT
Bug 64015 InvocationTargetException during Extract Constant [refactoring]
Reported: 2004-05-25 19:00:51 | Status: verified fixed

Version 3.0.m9. I got the InvocationTargetException below when I clicked OK to a Extract Constant refactoring. In the method: byte[] allocateBuffer(String cics, String program, String user, String password, int timeOutSeconds, byte[] data) throws UnsupportedEncodingException { int minLen = IN_BUFLEN_CICS + IN_BUFLEN_PROGRAM + IN_BUFLEN_USER + IN_BUFLEN_PASSWORD + IN_BUFLEN_TIMEOUT + IN_BUFLEN_DATALEN; byte[] buffer = new byte[minLen + data.length]; int index = 0; this.copy(cics, buffer, index, IN_BUFLEN_CICS); index += IN_BUFLEN_CICS; this.copy(program, buffer, index, IN_BUFLEN_PROGRAM); index += IN_BUFLEN_PROGRAM; this.copy(user, buffer, index, IN_BUFLEN_USER); index += IN_BUFLEN_USER; this.copy(password, buffer, index, IN_BUFLEN_PASSWORD); index += IN_BUFLEN_PASSWORD; this.copy(timeOutSeconds, buffer, index, IN_BUFLEN_TIMEOUT); index += IN_BUFLEN_TIMEOUT; this.copy(data.length, buffer, index, IN_BUFLEN_DATALEN); index += IN_BUFLEN_DATALEN; this.copy(data, buffer, index, data.length); index += data.length; return buffer; } I selected: IN_BUFLEN_CICS + IN_BUFLEN_PROGRAM + IN_BUFLEN_USER + IN_BUFLEN_PASSWORD + IN_BUFLEN_TIMEOUT + IN_BUFLEN_DATALEN Then I right-clicked Refactor/Extract Constant, set the name to "MIN_IN_BUFLEN", chose the scope to be package private, click OK and got: !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 May 25, 2004 15:42:57.207 !MESSAGE Internal Error !STACK 0 java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:282) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.internalPerformFinish(RefactoringWizard.java:533) at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.performFinish(UserInputWizardPage.java:153) at org.eclipse.ltk.ui.refactoring.RefactoringWizard.performFinish(RefactoringWizard.java:599) at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.okPressed(RefactoringWizardDialog2.java:406) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:365) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:505) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.jface.window.Window.runEventLoop(Window.java:668) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExtractConstantAction.run(ExtractConstantAction.java:94) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:899) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:850) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionContributionItem.java:769) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:97) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:307) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:256) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) 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.dom.fragments.ASTFragmentFactory.createFragmentForFullSubtree(ASTFragmentFact ory.java:55) at org.eclipse.jdt.internal.corext.dom.fragments.AssociativeInfixExpressionFragment.getMatchingFragmentsWithNode (AssociativeInfixExpressionFragment.java:136) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.visitNode(ASTMatchingFragmentFinder.j ava:42) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit(GenericVisitor.java:338) at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:256) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2526) at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:200) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2503) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:487) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatches(ASTMatchingFragmentFinder .java:34) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatchingFragments(ASTMatchingFrag mentFinder.java:22) at org.eclipse.jdt.internal.corext.dom.fragments.SimpleFragment.getSubFragmentsMatching(SimpleFragment.java:38) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getFragmentsToReplace(ExtractCons tantRefactoring.java:855) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.createReplaceExpressionWithConsta ntEdits(ExtractConstantRefactoring.java:602) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getAllEdits(ExtractConstantRefact oring.java:482) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkCompilation(ExtractConstantR efactoring.java:421) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkFinalConditions(ExtractConst antRefactoring.java:409) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) 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.dom.fragments.ASTFragmentFactory.createFragmentForFullSubtree(ASTFragmentFact ory.java:55) at org.eclipse.jdt.internal.corext.dom.fragments.AssociativeInfixExpressionFragment.getMatchingFragmentsWithNode (AssociativeInfixExpressionFragment.java:136) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.visitNode(ASTMatchingFragmentFinder.j ava:42) at org.eclipse.jdt.internal.corext.dom.GenericVisitor.visit(GenericVisitor.java:338) at org.eclipse.jdt.core.dom.TagElement.accept0(TagElement.java:256) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2526) at org.eclipse.jdt.core.dom.Javadoc.accept0(Javadoc.java:200) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2503) at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:487) at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2456) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatches(ASTMatchingFragmentFinder .java:34) at org.eclipse.jdt.internal.corext.dom.fragments.ASTMatchingFragmentFinder.findMatchingFragments(ASTMatchingFrag mentFinder.java:22) at org.eclipse.jdt.internal.corext.dom.fragments.SimpleFragment.getSubFragmentsMatching(SimpleFragment.java:38) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getFragmentsToReplace(ExtractCons tantRefactoring.java:855) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.createReplaceExpressionWithConsta ntEdits(ExtractConstantRefactoring.java:602) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.getAllEdits(ExtractConstantRefact oring.java:482) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkCompilation(ExtractConstantR efactoring.java:421) at org.eclipse.jdt.internal.corext.refactoring.code.ExtractConstantRefactoring.checkFinalConditions(ExtractConst antRefactoring.java:409) at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84) at org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114) at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:182) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1672) 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 extension/org/eclipse/jdt/internal/corext/dom/fragments/ASTMatchingFragmentFinder.java