RFR: 8238494: Odd behavior when using VarHandle::toMethodHandle on a memory access handle
Jorn Vernee
jvernee at openjdk.java.net
Wed Feb 5 12:33:29 UTC 2020
On Tue, 4 Feb 2020 22:42:25 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> Hi,
> this change fixes a bug introduced by the recently pushed VarHandle adaptation support. More specifically, when calling `VarHandle::toMethodHandle` on a memory access handle, some spurious index out of bound exception is generated. This is caused by the fact that when `IndirectVarHandle::toMethodHandle` generates the required method handle, it binds it against `this`, rather than against the leaf direct var handle. Which means we're calling a method handle which expects a certain kind of a VarHandle (a memory access handle) with a different VarHandle which has no associated offset information. In fact, the memory access var handle helper classes will try to read the `offset` field from a class that doesn't have it - resulting in a spurious read.
>
> I've updated the adapter test to do the final get in the various tests through a method handle obtained by the corresponding adapted var handle.
>
> Cheers
> Maurizio
LGTM
-------------
Marked as reviewed by jvernee (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/4
More information about the panama-dev
mailing list