RFR: 8238494: Odd behavior when using VarHandle::toMethodHandle on a memory access handle

Maurizio Cimadamore mcimadamore at openjdk.java.net
Tue Feb 4 22:57:02 UTC 2020


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

-------------

Commits:
 - c06b8c46: Fix for OOB thrown when accessing memory access VarHandle using MH getter

Changes: https://git.openjdk.java.net/panama-foreign/pull/4/files
 Webrev: https://webrevs.openjdk.java.net/panama-foreign/4/webrev.00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8238494
  Stats: 12 lines in 2 files changed: 0 ins; 0 del; 12 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/4.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/4/head:pull/4

PR: https://git.openjdk.java.net/panama-foreign/pull/4


More information about the panama-dev mailing list