Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Error when inlining array.length expression #1705

Closed
HannesWell opened this issue Sep 28, 2024 · 11 comments · Fixed by #1718
Closed

Internal Error when inlining array.length expression #1705

HannesWell opened this issue Sep 28, 2024 · 11 comments · Fixed by #1718
Assignees
Labels
bug Something isn't working

Comments

@HannesWell
Copy link
Contributor

When I try to inline (Alt + Shift+ I) the length in the following code snippet

public static void main(String[] args) {
	String[] a = new String[0];
	int length = a.length;
	if (length > 0) {
		System.out.println("Longer"); //$NON-NLS-1$
	}
}

it fails with the following error:

java.lang.reflect.InvocationTargetException
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:396)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:470)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:230)
	at org.eclipse.ui.internal.progress.ProgressManager.lambda$26(ProgressManager.java:819)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:849)
	at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:828)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.checkInitialConditions(RefactoringWizardOpenOperation.java:222)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.lambda$0(RefactoringWizardOpenOperation.java:173)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:209)
	at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:126)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:41)
	at org.eclipse.jdt.internal.corext.refactoring.RefactoringExecutionStarter.startInlineTempRefactoring(RefactoringExecutionStarter.java:351)
	at org.eclipse.jdt.ui.actions.InlineTempAction.tryInlineTemp(InlineTempAction.java:121)
	at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:120)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
	at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:252)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:474)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:124)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:98)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:299)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:233)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:174)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:165)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:485)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:204)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:569)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:644)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:91)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1319)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1173)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1198)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1183)
	at org.eclipse.swt.widgets.Control.traverse(Control.java:4234)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:4084)
	at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:1259)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:4102)
	at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:4991)
	at org.eclipse.swt.widgets.Display.filterMessage(Display.java:1337)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3708)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1042)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:639)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:546)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:173)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:208)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:143)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:109)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:439)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:271)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:668)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:605)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1481)
Caused by: java.lang.IllegalArgumentException: Invalid identifier : >String[]<
	at org.eclipse.jdt.core.dom.SimpleName.setIdentifier(SimpleName.java:247)
	at org.eclipse.jdt.core.dom.AST.newSimpleName(AST.java:2935)
	at org.eclipse.jdt.core.dom.AST.newName(AST.java:2561)
	at org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring.createFullyQualifiedName(InlineTempRefactoring.java:779)
	at org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring.createFullyQualifiedName(InlineTempRefactoring.java:752)
	at org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring.getAlternativeQualifications(InlineTempRefactoring.java:658)
	at org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring.checkClashes(InlineTempRefactoring.java:264)
	at org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring.checkInitialConditions(InlineTempRefactoring.java:250)
	at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2457)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2482)
	at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:89)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:124)
@srikanth-sankaran
Copy link

@mpalat - why am I not able to assign it to @subyssurendran666 - what exactly is the problem with that user id ??

Problem reproduced on master/HEAD.

@subyssurendran666 - could you take a look ? TIA

@srikanth-sankaran
Copy link

@mpalat - I have assigned it to you - please reassign ;-)

@subyssurendran666
Copy link

@srikanth-sankaran, There is an issue with my GitHub account that I'm unable to resolve. A ticket can only be assigned to me if I'm already part of the discussion. Since I've added a comment, you should be able to assign the ticket to me now.

@srikanth-sankaran
Copy link

@srikanth-sankaran, There is an issue with my GitHub account that I'm unable to resolve. A ticket can only be assigned to me if I'm already part of the discussion. Since I've added a comment, you should be able to assign the ticket to me now.

Has this been reported to the suitable admin ?

Anyways, the ticket is yours. If your investigation points to the problem elsewhere, suitably reassign. Thanks!

@jukzi jukzi added the bug Something isn't working label Sep 30, 2024
@HannesWell
Copy link
Contributor Author

@mpalat - why am I not able to assign it to @subyssurendran666 - what exactly is the problem with that user id ??

As far as I can tell you can only assign an issue to somebody that has participated in a conversation or is a committer of the project. So I assume he isn't a committer, is he?

@srikanth-sankaran
Copy link

@mpalat - why am I not able to assign it to @subyssurendran666 - what exactly is the problem with that user id ??

As far as I can tell you can only assign an issue to somebody that has participated in a conversation or is a committer of the project. So I assume he isn't a committer, is he?

Ah, I see. Thanks for that pointer @HannesWell - I had no idea!

@subyssurendran666
Copy link

Screenshot 2024-10-09 at 11 04 03 AM

I believe the issue is with the InlineTempRefactoring.createFullyQualifiedName() method in JDT UI. The createFullyQualifiedName method is supposed to return a fullyQualifiedName, as the AST DOM is expecting one. In this case, the DOM is expecting a.length, but it is receiving String[].length instead.

@srikanth-sankaran could you please move to JDT.UI.

@srikanth-sankaran srikanth-sankaran transferred this issue from eclipse-jdt/eclipse.jdt.core Oct 9, 2024
@srikanth-sankaran
Copy link

Thanks for the analysis @subyssurendran666

@noopur2507 could you take over please ? TIA

@subyssurendran666 subyssurendran666 removed their assignment Oct 10, 2024
@noopur2507
Copy link
Member

The code was added via https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/71284.
@NikolayMetchev / @jjohnstn, could you please take a look?

@NikolayMetchev
Copy link
Contributor

A decade later? I don't remember anything. I haven't used eclipse in about 7 years

@jjohnstn
Copy link
Contributor

I will look at it.

@jjohnstn jjohnstn self-assigned this Oct 15, 2024
jjohnstn added a commit to jjohnstn/eclipse.jdt.ui-1 that referenced this issue Oct 15, 2024
- fix InlineTempRefactoring.getAlternativeQualification() to not
  calculate qualified alternatives if not dealing with static reference
- fix InlineTempRefactoring.checkClashes() to handle when there are
  qualified alternatives
- add new test to InlineTempTests
- fixes eclipse-jdt#1705
jjohnstn added a commit that referenced this issue Oct 15, 2024
- fix InlineTempRefactoring.getAlternativeQualification() to not
  calculate qualified alternatives if not dealing with static reference
- fix InlineTempRefactoring.checkClashes() to handle when there are
  qualified alternatives
- add new test to InlineTempTests
- fixes #1705
jannisCode pushed a commit to jannisCode/eclipse.jdt.ui that referenced this issue Oct 20, 2024
…e-jdt#1718)

- fix InlineTempRefactoring.getAlternativeQualification() to not

  calculate qualified alternatives if not dealing with static reference

- fix InlineTempRefactoring.checkClashes() to handle when there are

  qualified alternatives

- add new test to InlineTempTests

- fixes eclipse-jdt#1705
jannisCode pushed a commit to jannisCode/eclipse.jdt.ui that referenced this issue Oct 22, 2024
…e-jdt#1718)

- fix InlineTempRefactoring.getAlternativeQualification() to not

  calculate qualified alternatives if not dealing with static reference

- fix InlineTempRefactoring.checkClashes() to handle when there are

  qualified alternatives

- add new test to InlineTempTests

- fixes eclipse-jdt#1705
jannisCode pushed a commit to jannisCode/eclipse.jdt.ui that referenced this issue Oct 22, 2024
…e-jdt#1718)

- fix InlineTempRefactoring.getAlternativeQualification() to not

  calculate qualified alternatives if not dealing with static reference

- fix InlineTempRefactoring.checkClashes() to handle when there are

  qualified alternatives

- add new test to InlineTempTests

- fixes eclipse-jdt#1705
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants