> On 23 Feb 2017, at 13:39, Uwe Schindler <[email protected]> wrote:
> 
> Thanks Remi.
> 
> Of course that would work, but the goal was to try VarHandles as generic way 
> to access on-heap and off-heap structures. Maybe Paul Sandoz has an answer to 
> this API inconsistency.
> 

It’s just that, an inconsistency, something i did not focus on w.r.t. 
use-cases, same for expanding the types supported for aligned atomic access, 
since we added field/array support for those quite late in the process and it’s 
a pain to deal with big/little endian cases read-modify-write ops (such as 
getAndAdd).

In effect the following VarHandles would then provide equivalent access 
functionality:

  VarHandle v1 = MethodHandles.arrayElementVarHandle(byte[].class);
  VarHandle v2 = MethodHandles.byteArrayViewVarHandle(byte[].class, 
ByteOrder.BIG_ENDIAN);
  VarHandle v3 = MethodHandles.byteBufferViewVarHandle(byte[].class, 
ByteOrder.LITTLE_ENDIAN);
  // Where for v3 a ByteBuffer instance is a heap buffer wrapping a byte[] array

We can certainly do this for 10.

Paul.




> Uwe
> 
> Am 23. Februar 2017 22:31:35 MEZ schrieb [email protected]:
> Hi Uwe,
> I've not the definitive answer, but you can create a MethodHandle on 
> ByteBuffer::get and see a VarHandle as a MethodHandle (with 
> VarHandler.toMethodHandle) so both access can be represented as method 
> handles.
> 
> Rémi
> 

Reply via email to