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

Florian Weimer fw at deneb.enyo.de
Sat Apr 11 11:23:13 UTC 2020


* Brian Burkhalter:

> To fix [1] this additional verbiage is proposed for the class specification of MappedByteBuffer:
>
> @@ -58,6 +58,9 @@
>   * avoid the manipulation of a mapped file by this program, or by a
>   * concurrently running program, except to read or write the file's content.
>   *
> + * <p> The result of a bulk copy between two {@code MappedByteBuffer}s is
> + * unspecified if they are mapped from overlapping regions of the same file.
> + *
>   * <p> Mapped byte buffers otherwise behave no differently than ordinary direct
>   * byte buffers. </p>
>
> Please refer also to [2].

In principle, this also applies to direct buffer created via JNI's
NewDirectByteBuffer.  Such direct buffers could alias with each other
or even MappedByteBuffer instances.


More information about the nio-dev mailing list