RFR : 8221696: MappedByteBuffer.force method to specify range

Alan Bateman Alan.Bateman at oracle.com
Tue Apr 9 17:59:30 UTC 2019


On 09/04/2019 11:42, Andrew Dinn wrote:
> Could I please get reviews for the following patch which overloads
> MappedByteBuffer.force to accept a start offset and length.
>
> JIRA:   https://bugs.openjdk.java.net/browse/JDK-8221696
> webrev: http://cr.openjdk.java.net/~adinn/8221696/webrev.00
>
> This new API method was conceived as a preliminary change for JEP 352 to
> allow selective writeback of NVRAM-backed buffers. However, it has been
> implemented to provide a similar capability for file-mapped byte
> buffers.
There are a couple of implementation details to discuss but I'll stick 
to the API/javadoc for now so that you can create the CSR.

We discussed the method signature, parameter types, and the semantics in 
previous mails so I think they are all okay (meaning the first parameter 
is the index in the buffer of the first byte to write back and not an 
offset from the position). One nit is that the existing absolute methods 
name the parameter "index" and I think we should do the same here.

In the first sentence it might be better to say "a region" rather "some 
region". You could expand this paragraph with a second sentence, 
something like "The region starts at the given {@code index} in this 
buffer and is {@code length} bytes".

A suggestion for the description for the index and length parameters is 
copy the wording/style from the existing absolute methods, e.g.

@param index The index of the first byte of the regsion; must be 
non-negative and less than limit()
@param length The length of the region in bytes; must be non-negative 
and no larger than limit() - index
@throws IndexOutOfBoundException If the preconditions on the index and 
length do not hold.

-Alan




More information about the nio-dev mailing list