8242477: (bf) MappedByteBuffer should clarify copying between overlapping mappings

Alan Bateman Alan.Bateman at oracle.com
Fri Apr 24 09:24:29 UTC 2020


On 23/04/2020 03:08, Brian Burkhalter wrote:
> :
>
> --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template
> +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template
>
> @@ -125,7 +125,9 @@
>   * instance of one of these kinds of buffers refers to an 
> inaccessible region
>   * of memory then an attempt to access that region will not change 
> the buffer's
>   * content and will cause an unspecified exception to be thrown 
> either at the
> - * time of the access or at some later time.
> + * time of the access or at some later time.  The result of a bulk 
> copy between
> + * two direct buffers created via JNI is unspecified if they refer to
> + * overlapping regions of memory.
>   *
>   * <p> Whether a byte buffer is direct or non-direct may be determined by
>   * invoking its {@link #isDirect isDirect} method.  This method is 
> provided so
>
I think this opens the door to questions about bulk copy operations on 
direct buffers by allocateDirect too because they can be sliced and 
duplicated in interesting ways. So easy to create scenarios where there 
is copying where the source and target overlaps.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200424/3b1a4fa2/attachment.htm>


More information about the nio-dev mailing list