< prev index next >

test/jdk/java/foreign/TestMismatch.java

Print this page
*** 30,22 ***
  import java.util.ArrayList;
  import java.util.List;
  import java.util.concurrent.atomic.AtomicReference;
  import java.util.function.IntFunction;
  
- import jdk.incubator.foreign.MemoryLayouts;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import org.testng.annotations.DataProvider;
  import org.testng.annotations.Test;
  import static java.lang.System.out;
  import static org.testng.Assert.assertEquals;
  import static org.testng.Assert.assertThrows;
  
  public class TestMismatch {
  
!     final static VarHandle BYTE_HANDLE = MemoryLayouts.JAVA_BYTE.varHandle(byte.class);
  
      // stores a increasing sequence of values into the memory of the given segment
      static MemorySegment initializeSegment(MemorySegment segment) {
          for (int i = 0 ; i < segment.byteSize() ; i++) {
              BYTE_HANDLE.set(segment.asSlice(i), (byte)i);
--- 30,22 ---
  import java.util.ArrayList;
  import java.util.List;
  import java.util.concurrent.atomic.AtomicReference;
  import java.util.function.IntFunction;
  
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
+ import jdk.incubator.foreign.ValueLayout;
  import org.testng.annotations.DataProvider;
  import org.testng.annotations.Test;
  import static java.lang.System.out;
  import static org.testng.Assert.assertEquals;
  import static org.testng.Assert.assertThrows;
  
  public class TestMismatch {
  
!     final static VarHandle BYTE_HANDLE = ValueLayout.JAVA_BYTE.varHandle();
  
      // stores a increasing sequence of values into the memory of the given segment
      static MemorySegment initializeSegment(MemorySegment segment) {
          for (int i = 0 ; i < segment.byteSize() ; i++) {
              BYTE_HANDLE.set(segment.asSlice(i), (byte)i);

*** 110,11 ***
      }
  
      @Test
      public void testLarge() {
          // skip if not on 64 bits
!         if (MemoryLayouts.ADDRESS.byteSize() > 32) {
              try (ResourceScope scope = ResourceScope.newConfinedScope()) {
                  var s1 = MemorySegment.allocateNative((long) Integer.MAX_VALUE + 10L, 8, scope);
                  var s2 = MemorySegment.allocateNative((long) Integer.MAX_VALUE + 10L, 8, scope);
                  assertEquals(s1.mismatch(s1), -1);
                  assertEquals(s1.mismatch(s2), -1);
--- 110,11 ---
      }
  
      @Test
      public void testLarge() {
          // skip if not on 64 bits
!         if (ValueLayout.ADDRESS.byteSize() > 32) {
              try (ResourceScope scope = ResourceScope.newConfinedScope()) {
                  var s1 = MemorySegment.allocateNative((long) Integer.MAX_VALUE + 10L, 8, scope);
                  var s2 = MemorySegment.allocateNative((long) Integer.MAX_VALUE + 10L, 8, scope);
                  assertEquals(s1.mismatch(s1), -1);
                  assertEquals(s1.mismatch(s2), -1);
< prev index next >