input.rhs.array() is not always safe.  If it's a ByteBuffer created on the heap, then it will have an array, but technically, the ByteBuffer might have a position and limit different than 0 and array.length, in which case you will be surprised by what you get out (you get the backing array without any indication of position or limit or anything like that).  This just plain won't work with a ByteBuffer created by ByteBuffer.allocateDirect().

Either the signature should be adjusted to have an array(), or we should check to make sure that (1) there is an array and (2) the position and limit are equal to 0 and array.length, otherwise we have to create a new byte[] and write into that.