I got the UnsupportedOperationException in the following code:
byte[] temp = ByteBuffer.allocateDirect(10).array();
I checked the java specification, it says:
UnsupportedOperationException - If this buffer is not backed by an accessible array
Here are my questions:
(1) Is that mean if the byteBuffer is created through ByteBuffer.allocateDirect, this byteBuffer is always not backed by an accessible array?
(2) I know this byteBuffer is allocated outside of Java heap, but what's implementation of this allocation. Maybe through OS system call? So whether the array is accessible depends on the OS we use?
allocateDirect: "Whether or not it has a backing array is unspecified." So yes, it's all implementation-specific...