< prev index next >

test/jdk/java/foreign/TestHandshake.java

Print this page
@@ -29,11 +29,10 @@
   * @run testng/othervm -Xint TestHandshake
   * @run testng/othervm -XX:TieredStopAtLevel=1 TestHandshake
   * @run testng/othervm -XX:-TieredCompilation TestHandshake
   */
  
- import jdk.incubator.foreign.MemoryAccess;
  import jdk.incubator.foreign.MemorySegment;
  
  import java.lang.invoke.MethodHandles;
  import java.lang.invoke.VarHandle;
  import java.nio.ByteBuffer;

@@ -46,10 +45,12 @@
  import java.util.concurrent.atomic.AtomicLong;
  
  import jdk.incubator.foreign.ResourceScope;
  import org.testng.annotations.DataProvider;
  import org.testng.annotations.Test;
+ 
+ import static jdk.incubator.foreign.ValueLayout.JAVA_BYTE;
  import static org.testng.Assert.*;
  
  public class TestHandshake {
  
      static final int ITERATIONS = 5;

@@ -148,11 +149,11 @@
  
          @Override
          void doAccess() {
              int sum = 0;
              for (int i = 0; i < segment.byteSize(); i++) {
-                 sum += MemoryAccess.getByteAtOffset(segment, i);
+                 sum += segment.get(JAVA_BYTE, i);
              }
          }
      }
  
      static class SegmentCopyAccessor extends AbstractSegmentAccessor {

@@ -191,11 +192,11 @@
  
          SegmentMismatchAccessor(int id, MemorySegment segment) {
              super(id, segment);
              this.copy = MemorySegment.allocateNative(SEGMENT_SIZE, 1, segment.scope());
              copy.copyFrom(segment);
-             MemoryAccess.setByteAtOffset(copy, ThreadLocalRandom.current().nextInt(SEGMENT_SIZE), (byte)42);
+             copy.set(JAVA_BYTE, ThreadLocalRandom.current().nextInt(SEGMENT_SIZE), (byte)42);
          }
  
          @Override
          public void doAccess() {
              segment.mismatch(copy);
< prev index next >