Re: JVMTI_ERROR_INVALID_SLOT error after using AdviceAdapter.onMethodEnter
Haasip Satang <[email protected]> Thu, 8 Feb 2018 13:45:11 +0100
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CAEz-yfgZprCF9KREXrWUpJ=LAVjU3dz5Rg-2XGvVqNy_6kcNbg@mail.gmail.com> |
You are right, this really is a better way. Implemented it already: - in visitMethod I get the argument types (if any) and calculate the index of the first local variable that would come after "this" (for instance methods) AND potential arguments (considering their type sizes) - in onMethodEnter I visit a new Label followed by the invokestatic - in visitLocalVariable I now check if the index of the var is smaller than the calculated index above. If so I know I'm dealing with "this" or arguments and will use the new label as start Thanks a lot and sorry for not spotting that earlier. Was surprised to see this behaviour and wasn't sure if ASM behaves the way it should in this case. BTW: I just reproduced the problem with a debugger as well: - Write a simple agent that onMethodEnter adds something (e.g. a call to a static method) - Using Eclipse set a breakpoint on the line where method signature is declared (*not the first line of code in the method's body*) If you start the program in debug mode you will get the same error I ran into: com.sun.jdi.InternalException: Got error code in reply: 35 occured retrieving 'this' frm stack frame If you continue debugging everything will appear as expected in the variables view, etc. I guess not many people will have this problem, but whoever runs into this definitely needs to adjust the positions. Thanks again! 2018-02-08 11:55 GMT+01:00 Eliot Moss <[email protected]>: > Sorry for the series of emails ... > > The ASM docs describe how the local variable and line number information > can (should, in this case) be visited related to adding labels. You > would add a label at the beginning, before adding the invokestatic, > visit the label and then be in a position to update the local var and > line number information properly. See Section 4.3 of the ASM 4 guide. > > Cheers - EM > > > -- > You receive this message as a subscriber of the [email protected] mailing list. > To unsubscribe: mailto:[email protected] > For general help: mailto:[email protected]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws