public static MemorySegment wrapCopy(byte[] bytes, int start, int end)
            throws IllegalArgumentException {
        checkArgument(end >= start);
        checkArgument(end <= bytes.length);
        MemorySegment copy = allocateUnpooledSegment(end - start);
        copy.put(0, bytes, start, copy.size());
        return copy;
    }
@Test
    void testWrapPartialCopy() {
        byte[] data = {1, 2, 3, 5, 6};
        MemorySegment segment = MemorySegmentFactory.wrapCopy(data, 0, data.length / 2);
        byte[] exp = new byte[segment.size()];
        arraycopy(data, 0, exp, 0, exp.length);
        assertThat(segment.getHeapMemory()).containsExactly(exp);
    }