Re: JVMTI_ERROR_INVALID_SLOT error after using AdviceAdapter.onMethodEnter
Eliot Moss <[email protected]> Thu, 8 Feb 2018 05:37:15 -0500
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
On 2/8/2018 5:31 AM, Haasip Satang wrote: > Found the problem. It is indeed caused by the wrong start for the local variable "this" at slot 0. > As you also pointed out the original byte code now starts at position 3. > > So it seems that JVMTI does consider those values as well, which makes sense I guess as debuggers > usually are build on top of JVMTI (at least I wouldn't know another way). > > The problem in my app is that the jvmti agent sets a breakpoint to the start at the method --> > position 0. Since it is an instance method usually the "this" variable should be available at slot 0 > at this point already. After the instrumentation, however, the visibility for "this" only starts at > instruction 3. Therefore the agent cannot access "this" yet although being in the right stack frame. > > I worked around this in a hacky way now by patching the offset (the "position" field of the label) > to 0 inĀ visitLocalVariable if the name is "this" and offset != 0. This way it works. > > Am just wondering if there isn't a cleaner way to do this. While the byte code is perfectly valid > for the JVM in Java we would never get an instance method where "this" is not available at positon 0 > already. > What do you think? I believe you, though it surprises me that JVMTI would look at that information. I would have to dig deeply back into the ASM documentation / code, but I suspect there is a way to produce the Local Variable Table you want without having to "hack" it. But good work finding the problem! 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