RFR: JDK-8264110 (fs) possible UnsupportedOperationException in UnixUserDefinedFileAttributeView.read(...)

Alan Bateman alanb at openjdk.java.net
Fri Mar 26 16:59:25 UTC 2021


On Fri, 26 Mar 2021 15:11:54 GMT, Sebastian Stenzel <github.com+1204330+overheadhunter at openjdk.org> wrote:

> During `write()`, we check whether the `src` buffer exposes a raw byte array:
> 
> https://github.com/openjdk/jdk/blob/4e74de4b2eec611b49ee8defae1ab06351280008/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java#L247-L258
> 
> The same is now also done during `read()`. This should allow using arbitrary ByteBuffer implementations as `dst` and restores a certain symmetry between read and write.

src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java line 197:

> 195:                     unsafe.copyMemory(null, address, tmp, 0, n);
> 196:                     dst.put(tmp);
> 197:                 }

The changes look okay but I'm wondering what cases you have in mind so that we can add tests. We lack tests that use of these APIs with buffers that are created with JNI NewDirectByteBuffer.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3217


More information about the nio-dev mailing list