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

[BUG] Eclipse 4.23 refactor/rename from within Java Source Editor throws java.lang.VerifyError: Bad type on operand stack #3134

Closed
andi-huber opened this issue Mar 12, 2022 · 26 comments · Fixed by #3136
Assignees
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse
Milestone

Comments

@andi-huber
Copy link

andi-huber commented Mar 12, 2022

Given a fresh Eclipse install from upcoming 4.23.0 Release (Candidate Build: 4.23RC2a), it appears that when Lombok is installed as java agent in eclipse.ini

...
-vmargs
-javaagent:xxx\eclipse\lombok-1.18.22.jar
...

the Eclipse refactor feature no longer works from within the Source Editor window.

NOTICE

UPDATE March 22, 2022
A snapshot build (to use before release v1.18.24), that fixes the issue, is provided here https://github.com/projectlombok/lombok/files/8274291/lombok.zip

To Reproduce
Given plain Java (no Lombok) ...

public static void main(String[] args) {
   var message = "Hallo World";
   System.out.println(message);
}

when trying to refactor/rename the message variable (e.g. select the text and use the context menu), Eclipse throws a java.lang.VerifyError.

Version info:

  • Lombok version 1.18.22, but also a latest build from the 'master' branch has same issue
  • Platform Windows with Java 17.0.2 as shipped with the Eclipse Release Candidate (Candidate Build: 4.23RC2a)

Additional context
Eclipse also has a Code Outline view, from where one can initiate a refactor/rename e.g. on class fields. It appears that with that there are no issues.

@andi-huber
Copy link
Author

eclipse.buildId=4.23.0.I20220223-1800
java.version=17.0.2
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

This is a continuation of log file D:\development\workspaces\oxygen\.metadata\.bak_0.log
Created Time: 2022-03-12 06:45:50.206

org.eclipse.ui
Error
Sat Mar 12 06:45:50 CET 2022
Unhandled event loop exception

java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    org/eclipse/jdt/internal/corext/dom/LinkedNodeFinder.findByNode(Lorg/eclipse/jdt/core/dom/ASTNode;Lorg/eclipse/jdt/core/dom/Name;)[Lorg/eclipse/jdt/core/dom/Name; @11: invokestatic
  Reason:
    Type '[Lorg/eclipse/jdt/core/dom/Name;' (current frame, stack[0]) is not assignable to '[Lorg/eclipse/jdt/core/dom/SimpleName;'
  Current Frame:
    bci: @11
    flags: { }
    locals: { 'org/eclipse/jdt/core/dom/ASTNode', 'org/eclipse/jdt/core/dom/Name', '[Lorg/eclipse/jdt/core/dom/Name;' }
    stack: { '[Lorg/eclipse/jdt/core/dom/Name;' }
  Bytecode:
    0000000: 2a2b b801 044d 2cc6 0008 2cb8 016b b02b
    0000010: b601 06b6 00f6 3e1d 101e 9f00 0f1d 100a
    0000020: 9f00 091d 1012 a000 32bb 00d0 59b7 00d2
    0000030: 3a04 bb01 0959 2b19 04b7 010b 3a05 2a19
    0000040: 05b6 00d8 1904 1904 b600 dcbd 0107 b600
    0000050: dfc0 010e b801 6bb0 04bd 0107 5903 2b53
    0000060: b801 6bb0                              
  Stackmap Table:
    append_frame(@15,Object[#270])
    append_frame(@41,Integer)
    same_frame(@88)

	at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode.start(RenameLinkedMode.java:238)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:250)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.doRun(RenameJavaElementAction.java:190)
	at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:162)
	at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:121)
	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:121)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
	at jdk.internal.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:647)
	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:89)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1280)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1087)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1072)
	at org.eclipse.swt.widgets.Control.traverse(Control.java:4260)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:4110)
	at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:1251)
	at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:1254)
	at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:4128)
	at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:4916)
	at org.eclipse.swt.widgets.Display.filterMessage(Display.java:1298)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3628)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)

@Rawi01 Rawi01 self-assigned this Mar 13, 2022
@Rawi01 Rawi01 added bug eclipse accepted The issue/enhancement is valid, sensible, and explained in sufficient detail labels Mar 13, 2022
@rzwitserloot
Copy link
Collaborator

Relevant source files:

  • SimpleName (a subclass of Name).
  • Line 238 in RenameLinkedMode indeed appears to invoke LinkedNodeFinder.findByNode.
  • Just looking at it, I don't get this error - there are 2 overloads for findByNode; one based on SimpleName which returns SimpleName[], and one based on Name which returns Name[] - the Name based version is involved as per the signature in that error, but it whinges that a Name[] is not assignable to SimpleName[]. Sure, but.. which code is attempting to do that, then? These are the 'latest' versions I linked to. I'd have expected this if the findByNode overloads had been unified into a single method or some such.

@rzwitserloot
Copy link
Collaborator

In that code, the result is in fact assigned to an ASTNode[],but that's a local var so type info is presumably not verified there. More generally in JVMese you can just assign a Child[] ref to a place where Parent[] is expected and this works even though variance wise it shouldn't - that's just how java is defined. If it was our code that means we can just return a SimpleName[] where previously we returned a Name[], but it doesn't appear to (directly) be our code - or am I missing something and is this a method we are agent-modifying?

@rzwitserloot
Copy link
Collaborator

D'oh, @Rawi01 already figured it out.

@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 13, 2022

I self-assigned it to let you know that I'm working on it 😄

The Name[] method is the new one and it fails because it tries to call the SimpleName[] patch. Our old patch code changed both methods so I had to modify it and add a new patch for the new method.

@andi-huber
Copy link
Author

Impressive response time. Fix works for me. Thank you so much!

@aasjpvm
Copy link

aasjpvm commented Mar 16, 2022

hope all can be solved soon, I find this same issue today when updated accidentally eclipse

@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 16, 2022

JDK 18 (release in 6 days) also requires some changes so I guess there might be a new release version soon. I uploaded a pre-built version if you need the fix right now.

@jakobklein
Copy link

Thx for the quick fix. The pre-built works for me.

@dstango
Copy link

dstango commented Mar 21, 2022

Can we get an updated snapshot version? As people update to Eclipse 2022-03 they come over to the eclipse side with puzzled bug reports, and there are surely more that don't report it but blame it on Eclipse ...
Would be great to have be easily able to help them out at least with the snapshot version.

@rzwitserloot
Copy link
Collaborator

The current snapshot version is updated, no?

@andi-huber
Copy link
Author

I updated the issue description, in case people land on this issue page, coming from any context, so they quickly get directed to the fixed snapshot download.

@dstango
Copy link

dstango commented Mar 22, 2022

The current snapshot version is updated, no?

This guy says it isn't: https://bugs.eclipse.org/bugs/show_bug.cgi?id=579339

(I couldn't check yet as I'm still on a working milestone build of Eclipse)

@andi-huber
Copy link
Author

I updated the link to the fixed version in the description (https://github.com/projectlombok/lombok/files/8274291/lombok.zip).
(just in case the edge version is not up to speed - did not check)

@dstango
Copy link

dstango commented Mar 22, 2022

thanks!

@dstango
Copy link

dstango commented Mar 22, 2022

Question: might this issue be related, too? https://bugs.eclipse.org/bugs/show_bug.cgi?id=579341

@davidsedlar
Copy link

davidsedlar commented Mar 23, 2022

I was so perturbed as to why my new Eclipse won't rename anything anymore! Thanks for the quick fix, Lombok is the best!

@shankarwww
Copy link

It seems the issue is still not completely fixed. Try to rename the file using Crtl+Shift+R by clicking the on the file in the package explorer. The window and different options in the toolbar menu starts flickering.

@Rawi01
Copy link
Collaborator

Rawi01 commented Mar 28, 2022

@shankarwww If I press Ctrl+Shift+R it opens a seperate rename dialog and I cannot see any flickering. Can you share some more details?

@shankarwww
Copy link

sts_flickering_issue

please find the details in above pic

@dstango
Copy link

dstango commented Mar 29, 2022

I had a "flickering issue" with something totally unrelated to lombok, but what was the same was that the keyboard shortcut was ambiguous - I had two commands associated to the same key binding.
Looks like that's the case here.
Suggestions:

  • remove keybinding of rename and see if issue persists.
  • if this helps, please file a bug on the eclipse side because of the flickering.

@dstango
Copy link

dstango commented Mar 29, 2022

@shankarwww Hopefully this will help resolve it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=579483

@user20161119
Copy link

user20161119 commented Apr 22, 2022

after i tested with 1.18.24 and sts Version: 4.14.0.RELEASE
Build Id: 202203131612

the rename not working,
image

and then i uninstall lombok,rename work again
image

@rzwitserloot
Copy link
Collaborator

@user20161119 In eclipse menu: Window, Show View, Error Log. Fetch the relevant log and paste the exception trace and all details. Because we fixed this, and I don't have an STS installation handy.

@user20161119
Copy link

@user20161119 In eclipse menu: Window, Show View, Error Log. Fetch the relevant log and paste the exception trace and all details. Because we fixed this, and I don't have an STS installation handy.

I rolled back to following version ,and it's work
image

@rzwitserloot
Copy link
Collaborator

@user20161119 That is not the error log. The error log contains, well, errors, and generally includes a stack trace. There's nothing we can do (short of just downloading STS, clicking around, and praying we hit the same issue. We're not going to do that) without this information, and the issue will remain closed until it is provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/enhancement is valid, sensible, and explained in sufficient detail bug eclipse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants