IntArray { public int[] toJvmArray() throws IndexOutOfBoundsException { if (length > Integer.MAX_VALUE) { throw new IndexOutOfBoundsException( "array size (" + length + ") too large and cannot be converted into JVM array"); } final int[] arr = new int[(int) length]; PlatformDependent.UNSAFE.copyMemory( baseObj, baseOffset, arr, ARRAY_OFFSET, length * WIDTH); return arr; } IntArray(MemoryBlock memory); MemoryBlock memoryBlock(); long size(); void set(long index, int value); int get(long index); int[] toJvmArray();  }
@Test public void toJvmArray() { IntArray arr = createTestData(); int[] expected = {1, 2, 3, 5}; Assert.assertArrayEquals(expected, arr.toJvmArray()); }