RFR: 8207851 JEP Draft: Support ByteBuffer mapped over non-volatile memory

Andrew Dinn adinn at redhat.com
Tue Feb 19 18:01:12 UTC 2019


Hi Alan,

Thanks for following this up.

On 19/02/2019 16:55, Alan Bateman wrote:

> The issues with the 2-arg force method that I think need discussion are:
> 
> 1. long from/to vs. from/length vs int index/length. Elements in
> buffers, or the starting index of a region, are addressed by an int
> index in the existing API. We are currently discussing absolute bulk
> get/put methods on nio-dev right now and the methods on the table use
> "int length", this is mostly because they are about bulk copying in/out
> of byte arrays where offet+length is the norm.

I agree that the force method should take int arguments to align with
other methods. Also, I think they should be offset+length for the same
reason. I will modify the JEP and the next webrev accordingly.

> 2. limit vs. capacity. If I read the webrev correctly, it checks the
> upper bound against the buffer capacity. I don't think we have any
> existing methods where you can specify an index that is >= limit.

I agree that for consistency with other methods it would be better to
check against limit(). I will modify the next webrev accordingly modulo
resolution of one small detail.

My reason for using capacity() was that I was swayed by the original
implementation of force(). It calls

  force0(fd, mappingAddress(offset), mappingLength(offset))

where offset is

  long offset = mappingOffset();

The definition of mappingLength(offset) is

    private long mappingLength(long mappingOffset) {
        return (long)capacity() + mappingOffset;

I'm wondering if this ought to remain as is or ought to change to
specify limit()?

> 3. The javadoc doesn't specify the exception thrown when the bounds
> checks fail. In the webrev I see that IAE is thrown but the existing
> buffer methods specify IIOBE. If you agree then it means you can replace
> the checks with one method:
>    Objects.checkFromIndexSize(index, length, limit());

It sounds like a very good idea to use that method and hence to throw
IOOBE. I will modify the JEP and the next webrev accordingly.

regards,


Andrew Dinn
-----------
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham, Michael ("Mike") O'Neill, Eric Shander


More information about the core-libs-dev mailing list