Absolute index bulk put/get byte operations on ByteBuffer

Remi Forax forax at univ-mlv.fr
Fri Sep 7 12:22:09 UTC 2018


I wonder if it's not better to have a new copy mode on a VarHandle created from byteArrayViewVarHandle or byteBufferViewVarHandle with the same parameters as arraycopy ?

Rémi

----- Mail original -----
> De: "Alan Bateman" <Alan.Bateman at oracle.com>
> À: "Martin Thompson" <mjpt777 at gmail.com>, "nio-dev" <nio-dev at openjdk.java.net>
> Envoyé: Vendredi 7 Septembre 2018 12:43:24
> Objet: Re: Absolute index bulk put/get byte operations on ByteBuffer

> On 06/09/2018 20:42, Martin Thompson wrote:
>> There has been a long outstanding issue of ByteBuffer not having
>> methods to get or put a ByteBuffer or byte[] at an absolute index.
>>
>> https://bugs.openjdk.java.net/browse/JDK-5029431
>>
>> This seriously hampers the usefulness of ByteBuffer in a concurrent
>> environment due to contention on the position and limit fields.
>> Slicing or duplicating are not valid options are this are not
>> threadsafe and they allocate.
>>
>> Is there any reason why this bug has not been progressed?
> Many of the calls for absolute operations on ByteBuffers over the years
> have really been cases where someone wanted to operate on a region of
> memory and ended up using a direct buffer because they didn't have
> anything better. The buffer position/limit get in the way in many of
> these cases of course.
> 
> As regards JDK-5029431 then I think these methods should have been added
> a long time ago but adding them now does beg the question as to how
> ByteBuffers will interact with memory regions or similar concept that
> Project Panama may introduce. There is also the question of addressing
> with large files (mapping regions > 2GB). Stuart might want to comment
> on this as I think he has concerns about adding further methods here
> until some of these other interactions are worked out.
> 
> -Alan


More information about the nio-dev mailing list