DirectByteBuffer implements ByteBuffer { public void put(int position, byte[] source, int offset, int length) { copyFromArray(source, ARRAY_BASE_OFFSET, offset, getPosition(position), length); } DirectByteBuffer(final int capacity); static sun.misc.Unsafe getUnsafe(); void get(int position, byte[] destination, int offset, int length); void put(int position, byte[] source, int offset, int length); void free();  }
@Test public void put() { int size = 100; byte[] expectedBytes = new byte[size]; random.nextBytes(expectedBytes); buffer.put(0, expectedBytes, 0, expectedBytes.length); byte[] actualBytes = new byte[size]; buffer.get(0, actualBytes, 0, actualBytes.length); assertArrayEquals(expectedBytes, actualBytes); }