While discussing JDK-8264110, we came to the conclusion that ByteBuffers are either DirectByteBuffers or HeapByteBuffers [1]. ByteBuffer has a package-private constructor and might be a candidate for sealed classes eventually.
In other words: If we can be sure not to deal with a DirectByteBuffer, we can assert to have a HeapByteBuffer which always has a backing array. Therefore the distinction in [2] is superfluous and can be removed (or get replaced by a corresponding `assert`).
[1]: https://github.com/openjdk/jdk/pull/3217#discussion_r602733761
[2]: https://github.com/openjdk/jdk/blob/4e74de4b2eec611b49ee8defae1ab06351280008/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java#L247-L258
In other words: If we can be sure not to deal with a DirectByteBuffer, we can assert to have a HeapByteBuffer which always has a backing array. Therefore the distinction in [2] is superfluous and can be removed (or get replaced by a corresponding `assert`).
[1]: https://github.com/openjdk/jdk/pull/3217#discussion_r602733761
[2]: https://github.com/openjdk/jdk/blob/4e74de4b2eec611b49ee8defae1ab06351280008/src/java.base/unix/classes/sun/nio/fs/UnixUserDefinedFileAttributeView.java#L247-L258
- relates to
-
JDK-8264110 (fs) possible UnsupportedOperationException in UnixUserDefinedFileAttributeView.read(...)
-
- Closed
-