Path: blob/master/test/jdk/java/foreign/TestSegmentAllocators.java
41145 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/*25* @test26* @run testng/othervm TestSegmentAllocators27*/2829import jdk.incubator.foreign.*;3031import org.testng.annotations.*;3233import java.lang.invoke.VarHandle;34import java.nio.ByteBuffer;35import java.nio.ByteOrder;36import java.nio.DoubleBuffer;37import java.nio.FloatBuffer;38import java.nio.IntBuffer;39import java.nio.LongBuffer;40import java.nio.ShortBuffer;41import java.util.ArrayList;42import java.util.List;43import java.util.function.BiFunction;44import java.util.function.Function;45import java.util.stream.IntStream;46import java.util.stream.LongStream;4748import static org.testng.Assert.*;4950public class TestSegmentAllocators {5152final static int ELEMS = 128;53final static Class<?> ADDRESS_CARRIER = MemoryLayouts.ADDRESS.bitSize() == 64 ? long.class : int.class;5455@Test(dataProvider = "nativeScopes")56public <Z> void testAllocation(Z value, AllocationFactory allocationFactory, ValueLayout layout, AllocationFunction<Z> allocationFunction, Function<MemoryLayout, VarHandle> handleFactory) {57ValueLayout[] layouts = {58layout,59layout.withBitAlignment(layout.bitAlignment() * 2),60layout.withBitAlignment(layout.bitAlignment() * 4),61layout.withBitAlignment(layout.bitAlignment() * 8)62};63for (ValueLayout alignedLayout : layouts) {64List<MemorySegment> addressList = new ArrayList<>();65int elems = ELEMS / ((int)alignedLayout.byteAlignment() / (int)layout.byteAlignment());66ResourceScope[] scopes = {67ResourceScope.newConfinedScope(),68ResourceScope.newSharedScope()69};70for (ResourceScope scope : scopes) {71try (scope) {72SegmentAllocator allocator = allocationFactory.allocator(alignedLayout.byteSize() * ELEMS, scope);73for (int i = 0; i < elems; i++) {74MemorySegment address = allocationFunction.allocate(allocator, alignedLayout, value);75assertEquals(address.byteSize(), alignedLayout.byteSize());76addressList.add(address);77VarHandle handle = handleFactory.apply(alignedLayout);78assertEquals(value, handle.get(address));79}80boolean isBound = allocationFactory.isBound();81try {82allocationFunction.allocate(allocator, alignedLayout, value); //too much, should fail if bound83assertFalse(isBound);84} catch (OutOfMemoryError ex) {85//failure is expected if bound86assertTrue(isBound);87}88}89// addresses should be invalid now90for (MemorySegment address : addressList) {91assertFalse(address.scope().isAlive());92}93}94}95}9697static final int SIZE_256M = 1024 * 1024 * 256;9899@Test100public void testBigAllocationInUnboundedScope() {101try (ResourceScope scope = ResourceScope.newConfinedScope()) {102SegmentAllocator allocator = SegmentAllocator.arenaAllocator(scope);103for (int i = 8 ; i < SIZE_256M ; i *= 8) {104MemorySegment address = allocator.allocate(i, i);105//check size106assertEquals(address.byteSize(), i);107//check alignment108assertEquals(address.address().toRawLongValue() % i, 0);109}110}111}112113@Test(expectedExceptions = OutOfMemoryError.class)114public void testTooBigForBoundedArena() {115try (ResourceScope scope = ResourceScope.newConfinedScope()) {116SegmentAllocator allocator = SegmentAllocator.arenaAllocator(10, scope);117allocator.allocate(12);118}119}120121@Test122public void testBiggerThanBlockForBoundedArena() {123try (ResourceScope scope = ResourceScope.newConfinedScope()) {124SegmentAllocator allocator = SegmentAllocator.arenaAllocator(4 * 1024 * 2, scope);125allocator.allocate(4 * 1024 + 1); // should be ok126}127}128129@Test(dataProvider = "arrayScopes")130public <Z> void testArray(AllocationFactory allocationFactory, ValueLayout layout, AllocationFunction<Object> allocationFunction, ToArrayHelper<Z> arrayHelper) {131Z arr = arrayHelper.array();132ResourceScope[] scopes = {133ResourceScope.newConfinedScope(),134ResourceScope.newSharedScope()135};136for (ResourceScope scope : scopes) {137try (scope) {138SegmentAllocator allocator = allocationFactory.allocator(100, scope);139MemorySegment address = allocationFunction.allocate(allocator, layout, arr);140Z found = arrayHelper.toArray(address, layout);141assertEquals(found, arr);142}143}144}145146@DataProvider(name = "nativeScopes")147static Object[][] nativeScopes() {148return new Object[][] {149{ (byte)42, AllocationFactory.BOUNDED, MemoryLayouts.BITS_8_BE,150(AllocationFunction<Byte>) SegmentAllocator::allocate,151(Function<MemoryLayout, VarHandle>)l -> l.varHandle(byte.class) },152{ (short)42, AllocationFactory.BOUNDED, MemoryLayouts.BITS_16_BE,153(AllocationFunction<Short>) SegmentAllocator::allocate,154(Function<MemoryLayout, VarHandle>)l -> l.varHandle(short.class) },155{ (char)42, AllocationFactory.BOUNDED, MemoryLayouts.BITS_16_BE,156(AllocationFunction<Character>) SegmentAllocator::allocate,157(Function<MemoryLayout, VarHandle>)l -> l.varHandle(char.class) },158{ 42, AllocationFactory.BOUNDED,159MemoryLayouts.BITS_32_BE,160(AllocationFunction<Integer>) SegmentAllocator::allocate,161(Function<MemoryLayout, VarHandle>)l -> l.varHandle(int.class) },162{ 42f, AllocationFactory.BOUNDED, MemoryLayouts.BITS_32_BE,163(AllocationFunction<Float>) SegmentAllocator::allocate,164(Function<MemoryLayout, VarHandle>)l -> l.varHandle(float.class) },165{ 42L, AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_BE,166(AllocationFunction<Long>) SegmentAllocator::allocate,167(Function<MemoryLayout, VarHandle>)l -> l.varHandle(long.class) },168{ 42d, AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_BE,169(AllocationFunction<Double>) SegmentAllocator::allocate,170(Function<MemoryLayout, VarHandle>)l -> l.varHandle(double.class) },171{ MemoryAddress.ofLong(42), AllocationFactory.BOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.BIG_ENDIAN),172(AllocationFunction<MemoryAddress>) SegmentAllocator::allocate,173(Function<MemoryLayout, VarHandle>)l -> MemoryHandles.asAddressVarHandle(l.varHandle(ADDRESS_CARRIER)) },174175{ (byte)42, AllocationFactory.BOUNDED, MemoryLayouts.BITS_8_LE,176(AllocationFunction<Byte>) SegmentAllocator::allocate,177(Function<MemoryLayout, VarHandle>)l -> l.varHandle(byte.class) },178{ (short)42, AllocationFactory.BOUNDED, MemoryLayouts.BITS_16_LE,179(AllocationFunction<Short>) SegmentAllocator::allocate,180(Function<MemoryLayout, VarHandle>)l -> l.varHandle(short.class) },181{ (char)42, AllocationFactory.BOUNDED, MemoryLayouts.BITS_16_LE,182(AllocationFunction<Character>) SegmentAllocator::allocate,183(Function<MemoryLayout, VarHandle>)l -> l.varHandle(char.class) },184{ 42, AllocationFactory.BOUNDED,185MemoryLayouts.BITS_32_LE,186(AllocationFunction<Integer>) SegmentAllocator::allocate,187(Function<MemoryLayout, VarHandle>)l -> l.varHandle(int.class) },188{ 42f, AllocationFactory.BOUNDED, MemoryLayouts.BITS_32_LE,189(AllocationFunction<Float>) SegmentAllocator::allocate,190(Function<MemoryLayout, VarHandle>)l -> l.varHandle(float.class) },191{ 42L, AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_LE,192(AllocationFunction<Long>) SegmentAllocator::allocate,193(Function<MemoryLayout, VarHandle>)l -> l.varHandle(long.class) },194{ 42d, AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_LE,195(AllocationFunction<Double>) SegmentAllocator::allocate,196(Function<MemoryLayout, VarHandle>)l -> l.varHandle(double.class) },197{ MemoryAddress.ofLong(42), AllocationFactory.BOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.LITTLE_ENDIAN),198(AllocationFunction<MemoryAddress>) SegmentAllocator::allocate,199(Function<MemoryLayout, VarHandle>)l -> MemoryHandles.asAddressVarHandle(l.varHandle(ADDRESS_CARRIER)) },200201{ (byte)42, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_8_BE,202(AllocationFunction<Byte>) SegmentAllocator::allocate,203(Function<MemoryLayout, VarHandle>)l -> l.varHandle(byte.class) },204{ (short)42, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_16_BE,205(AllocationFunction<Short>) SegmentAllocator::allocate,206(Function<MemoryLayout, VarHandle>)l -> l.varHandle(short.class) },207{ (char)42, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_16_BE,208(AllocationFunction<Character>) SegmentAllocator::allocate,209(Function<MemoryLayout, VarHandle>)l -> l.varHandle(char.class) },210{ 42, AllocationFactory.UNBOUNDED,211MemoryLayouts.BITS_32_BE,212(AllocationFunction<Integer>) SegmentAllocator::allocate,213(Function<MemoryLayout, VarHandle>)l -> l.varHandle(int.class) },214{ 42f, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_32_BE,215(AllocationFunction<Float>) SegmentAllocator::allocate,216(Function<MemoryLayout, VarHandle>)l -> l.varHandle(float.class) },217{ 42L, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_BE,218(AllocationFunction<Long>) SegmentAllocator::allocate,219(Function<MemoryLayout, VarHandle>)l -> l.varHandle(long.class) },220{ 42d, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_BE,221(AllocationFunction<Double>) SegmentAllocator::allocate,222(Function<MemoryLayout, VarHandle>)l -> l.varHandle(double.class) },223{ MemoryAddress.ofLong(42), AllocationFactory.UNBOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.BIG_ENDIAN),224(AllocationFunction<MemoryAddress>) SegmentAllocator::allocate,225(Function<MemoryLayout, VarHandle>)l -> MemoryHandles.asAddressVarHandle(l.varHandle(ADDRESS_CARRIER)) },226227{ (byte)42, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_8_LE,228(AllocationFunction<Byte>) SegmentAllocator::allocate,229(Function<MemoryLayout, VarHandle>)l -> l.varHandle(byte.class) },230{ (short)42, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_16_LE,231(AllocationFunction<Short>) SegmentAllocator::allocate,232(Function<MemoryLayout, VarHandle>)l -> l.varHandle(short.class) },233{ (char)42, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_16_LE,234(AllocationFunction<Character>) SegmentAllocator::allocate,235(Function<MemoryLayout, VarHandle>)l -> l.varHandle(char.class) },236{ 42, AllocationFactory.UNBOUNDED,237MemoryLayouts.BITS_32_LE,238(AllocationFunction<Integer>) SegmentAllocator::allocate,239(Function<MemoryLayout, VarHandle>)l -> l.varHandle(int.class) },240{ 42f, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_32_LE,241(AllocationFunction<Float>) SegmentAllocator::allocate,242(Function<MemoryLayout, VarHandle>)l -> l.varHandle(float.class) },243{ 42L, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_LE,244(AllocationFunction<Long>) SegmentAllocator::allocate,245(Function<MemoryLayout, VarHandle>)l -> l.varHandle(long.class) },246{ 42d, AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_LE,247(AllocationFunction<Double>) SegmentAllocator::allocate,248(Function<MemoryLayout, VarHandle>)l -> l.varHandle(double.class) },249{ MemoryAddress.ofLong(42), AllocationFactory.UNBOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.LITTLE_ENDIAN),250(AllocationFunction<MemoryAddress>) SegmentAllocator::allocate,251(Function<MemoryLayout, VarHandle>)l -> MemoryHandles.asAddressVarHandle(l.varHandle(ADDRESS_CARRIER)) },252};253}254255@DataProvider(name = "arrayScopes")256static Object[][] arrayScopes() {257return new Object[][] {258{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_8_LE,259(AllocationFunction<byte[]>) SegmentAllocator::allocateArray,260ToArrayHelper.toByteArray },261{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_16_LE,262(AllocationFunction<short[]>) SegmentAllocator::allocateArray,263ToArrayHelper.toShortArray },264{ AllocationFactory.BOUNDED,265MemoryLayouts.BITS_32_LE,266(AllocationFunction<int[]>) SegmentAllocator::allocateArray,267ToArrayHelper.toIntArray },268{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_32_LE,269(AllocationFunction<float[]>) SegmentAllocator::allocateArray,270ToArrayHelper.toFloatArray },271{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_LE,272(AllocationFunction<long[]>) SegmentAllocator::allocateArray,273ToArrayHelper.toLongArray },274{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_LE,275(AllocationFunction<double[]>) SegmentAllocator::allocateArray,276ToArrayHelper.toDoubleArray },277{ AllocationFactory.BOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.LITTLE_ENDIAN),278(AllocationFunction<MemoryAddress[]>) SegmentAllocator::allocateArray,279ToArrayHelper.toAddressArray },280281282{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_8_BE,283(AllocationFunction<byte[]>) SegmentAllocator::allocateArray,284ToArrayHelper.toByteArray },285{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_16_BE,286(AllocationFunction<short[]>) SegmentAllocator::allocateArray,287ToArrayHelper.toShortArray },288{ AllocationFactory.BOUNDED,289MemoryLayouts.BITS_32_BE,290(AllocationFunction<int[]>) SegmentAllocator::allocateArray,291ToArrayHelper.toIntArray },292{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_32_BE,293(AllocationFunction<float[]>) SegmentAllocator::allocateArray,294ToArrayHelper.toFloatArray },295{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_BE,296(AllocationFunction<long[]>) SegmentAllocator::allocateArray,297ToArrayHelper.toLongArray },298{ AllocationFactory.BOUNDED, MemoryLayouts.BITS_64_BE,299(AllocationFunction<double[]>) SegmentAllocator::allocateArray,300ToArrayHelper.toDoubleArray },301{ AllocationFactory.BOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.BIG_ENDIAN),302(AllocationFunction<MemoryAddress[]>) SegmentAllocator::allocateArray,303ToArrayHelper.toAddressArray },304305{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_8_LE,306(AllocationFunction<byte[]>) SegmentAllocator::allocateArray,307ToArrayHelper.toByteArray },308{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_16_LE,309(AllocationFunction<short[]>) SegmentAllocator::allocateArray,310ToArrayHelper.toShortArray },311{ AllocationFactory.UNBOUNDED,312MemoryLayouts.BITS_32_LE,313(AllocationFunction<int[]>) SegmentAllocator::allocateArray,314ToArrayHelper.toIntArray },315{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_32_LE,316(AllocationFunction<float[]>) SegmentAllocator::allocateArray,317ToArrayHelper.toFloatArray },318{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_LE,319(AllocationFunction<long[]>) SegmentAllocator::allocateArray,320ToArrayHelper.toLongArray },321{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_LE,322(AllocationFunction<double[]>) SegmentAllocator::allocateArray,323ToArrayHelper.toDoubleArray },324{ AllocationFactory.UNBOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.LITTLE_ENDIAN),325(AllocationFunction<MemoryAddress[]>) SegmentAllocator::allocateArray,326ToArrayHelper.toAddressArray },327328329{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_8_BE,330(AllocationFunction<byte[]>) SegmentAllocator::allocateArray,331ToArrayHelper.toByteArray },332{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_16_BE,333(AllocationFunction<short[]>) SegmentAllocator::allocateArray,334ToArrayHelper.toShortArray },335{ AllocationFactory.UNBOUNDED,336MemoryLayouts.BITS_32_BE,337(AllocationFunction<int[]>) SegmentAllocator::allocateArray,338ToArrayHelper.toIntArray },339{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_32_BE,340(AllocationFunction<float[]>) SegmentAllocator::allocateArray,341ToArrayHelper.toFloatArray },342{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_BE,343(AllocationFunction<long[]>) SegmentAllocator::allocateArray,344ToArrayHelper.toLongArray },345{ AllocationFactory.UNBOUNDED, MemoryLayouts.BITS_64_BE,346(AllocationFunction<double[]>) SegmentAllocator::allocateArray,347ToArrayHelper.toDoubleArray },348{ AllocationFactory.UNBOUNDED, MemoryLayouts.ADDRESS.withOrder(ByteOrder.BIG_ENDIAN),349(AllocationFunction<MemoryAddress[]>) SegmentAllocator::allocateArray,350ToArrayHelper.toAddressArray },351};352}353354interface AllocationFunction<X> {355MemorySegment allocate(SegmentAllocator allocator, ValueLayout layout, X value);356}357358static class AllocationFactory {359private final boolean isBound;360private final BiFunction<Long, ResourceScope, SegmentAllocator> factory;361362private AllocationFactory(boolean isBound, BiFunction<Long, ResourceScope, SegmentAllocator> factory) {363this.isBound = isBound;364this.factory = factory;365}366367SegmentAllocator allocator(long size, ResourceScope scope) {368return factory.apply(size, scope);369}370371public boolean isBound() {372return isBound;373}374375static AllocationFactory BOUNDED = new AllocationFactory(true, SegmentAllocator::arenaAllocator);376static AllocationFactory UNBOUNDED = new AllocationFactory(false, (size, scope) -> SegmentAllocator.arenaAllocator(scope));377}378379interface ToArrayHelper<T> {380T array();381T toArray(MemorySegment segment, ValueLayout layout);382383ToArrayHelper<byte[]> toByteArray = new ToArrayHelper<>() {384@Override385public byte[] array() {386return new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };387}388389@Override390public byte[] toArray(MemorySegment segment, ValueLayout layout) {391ByteBuffer buffer = segment.asByteBuffer().order(layout.order());392byte[] found = new byte[buffer.limit()];393buffer.get(found);394return found;395}396};397398ToArrayHelper<short[]> toShortArray = new ToArrayHelper<>() {399@Override400public short[] array() {401return new short[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };402}403404@Override405public short[] toArray(MemorySegment segment, ValueLayout layout) {406ShortBuffer buffer = segment.asByteBuffer().order(layout.order()).asShortBuffer();407short[] found = new short[buffer.limit()];408buffer.get(found);409return found;410}411};412413ToArrayHelper<int[]> toIntArray = new ToArrayHelper<>() {414@Override415public int[] array() {416return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };417}418419@Override420public int[] toArray(MemorySegment segment, ValueLayout layout) {421IntBuffer buffer = segment.asByteBuffer().order(layout.order()).asIntBuffer();422int[] found = new int[buffer.limit()];423buffer.get(found);424return found;425}426};427428ToArrayHelper<float[]> toFloatArray = new ToArrayHelper<>() {429@Override430public float[] array() {431return new float[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };432}433434@Override435public float[] toArray(MemorySegment segment, ValueLayout layout) {436FloatBuffer buffer = segment.asByteBuffer().order(layout.order()).asFloatBuffer();437float[] found = new float[buffer.limit()];438buffer.get(found);439return found;440}441};442443ToArrayHelper<long[]> toLongArray = new ToArrayHelper<>() {444@Override445public long[] array() {446return new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };447}448449@Override450public long[] toArray(MemorySegment segment, ValueLayout layout) {451LongBuffer buffer = segment.asByteBuffer().order(layout.order()).asLongBuffer();452long[] found = new long[buffer.limit()];453buffer.get(found);454return found;455}456};457458ToArrayHelper<double[]> toDoubleArray = new ToArrayHelper<>() {459@Override460public double[] array() {461return new double[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };462}463464@Override465public double[] toArray(MemorySegment segment, ValueLayout layout) {466DoubleBuffer buffer = segment.asByteBuffer().order(layout.order()).asDoubleBuffer();467double[] found = new double[buffer.limit()];468buffer.get(found);469return found;470}471};472473ToArrayHelper<MemoryAddress[]> toAddressArray = new ToArrayHelper<>() {474@Override475public MemoryAddress[] array() {476return switch ((int)MemoryLayouts.ADDRESS.byteSize()) {477case 4 -> wrap(toIntArray.array());478case 8 -> wrap(toLongArray.array());479default -> throw new IllegalStateException("Cannot get here");480};481}482483@Override484public MemoryAddress[] toArray(MemorySegment segment, ValueLayout layout) {485return switch ((int)layout.byteSize()) {486case 4 -> wrap(toIntArray.toArray(segment, layout));487case 8 -> wrap(toLongArray.toArray(segment, layout));488default -> throw new IllegalStateException("Cannot get here");489};490}491492private MemoryAddress[] wrap(int[] ints) {493return IntStream.of(ints).mapToObj(MemoryAddress::ofLong).toArray(MemoryAddress[]::new);494}495496private MemoryAddress[] wrap(long[] ints) {497return LongStream.of(ints).mapToObj(MemoryAddress::ofLong).toArray(MemoryAddress[]::new);498}499};500}501}502503504