Helpers for MethodHandles.byteArrayViewVarHandle VarHandle
Paul Sandoz
paul.sandoz at oracle.com
Tue May 17 10:31:01 UTC 2016
Hi Jaroslav,
I would prefer not to spread such functionality beyond that of ByteBuffer and the VarHandle producing methods on MethodHandles. It’s an advanced feature so think ok if less visible.
Note at the moment a VarHandle produced for byte[]/ByteBuffer view is not cached but it is certainly possible to do so.
—
Separately, i may revisit the signatures for access to also include an alignment-offset argument (which is expected to be constant when looping) in addition to the index (e.g. byte-index = ao + (i << LOG_2_UNIT_SIZE)). Thus bringing alignment into the foreground where it is harder to forget about or ignore.
Paul.
> On 16 May 2016, at 15:48, Jaroslav Kameník <jaroslav at kamenik.cz> wrote:
>
> Hi,
>
> what do you thing about adding helper methods for this kind of VarHandle?
>
> It would be nice to have something like
>
> Long.getFrom[LE/BE](byte[] arr, int index) // LE/BE -> endianity
> Long.setTo[LE/BE](long val, byte[] arr, int index)
>
> or
>
> Arrays.getLongFrom[LE/BE](byte[] arr, int index)
> Arrays.setLongTo[LE/BE](long val, byte[] arr, int index)
>
>
> Jaroslav
More information about the core-libs-dev
mailing list