< prev index next >

test/jdk/java/foreign/TestSpliterator.java

Print this page
@@ -25,11 +25,10 @@
   * @test
   * @run testng TestSpliterator
   */
  
  import jdk.incubator.foreign.MemoryLayout;
- import jdk.incubator.foreign.MemoryLayouts;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import jdk.incubator.foreign.SequenceLayout;
  
  import java.lang.invoke.VarHandle;

@@ -38,26 +37,26 @@
  import java.util.Spliterator;
  import java.util.concurrent.CountedCompleter;
  import java.util.concurrent.RecursiveTask;
  import java.util.concurrent.atomic.AtomicLong;
  import java.util.stream.LongStream;
- import java.util.stream.StreamSupport;
  
+ import jdk.incubator.foreign.ValueLayout;
  import org.testng.annotations.*;
  
  import static org.testng.Assert.*;
  
  public class TestSpliterator {
  
-     static final VarHandle INT_HANDLE = MemoryLayout.sequenceLayout(MemoryLayouts.JAVA_INT)
-             .varHandle(int.class, MemoryLayout.PathElement.sequenceElement());
+     static final VarHandle INT_HANDLE = MemoryLayout.sequenceLayout(ValueLayout.JAVA_INT)
+             .varHandle(MemoryLayout.PathElement.sequenceElement());
  
      final static int CARRIER_SIZE = 4;
  
      @Test(dataProvider = "splits")
      public void testSum(int size, int threshold) {
-         SequenceLayout layout = MemoryLayout.sequenceLayout(size, MemoryLayouts.JAVA_INT);
+         SequenceLayout layout = MemoryLayout.sequenceLayout(size, ValueLayout.JAVA_INT);
  
          //setup
          try (ResourceScope scope = ResourceScope.newSharedScope()) {
              MemorySegment segment = MemorySegment.allocateNative(layout, scope);
              for (int i = 0; i < layout.elementCount().getAsLong(); i++) {

@@ -80,11 +79,11 @@
          }
      }
  
      @Test
      public void testSumSameThread() {
-         SequenceLayout layout = MemoryLayout.sequenceLayout(1024, MemoryLayouts.JAVA_INT);
+         SequenceLayout layout = MemoryLayout.sequenceLayout(1024, ValueLayout.JAVA_INT);
  
          //setup
          MemorySegment segment = MemorySegment.allocateNative(layout, ResourceScope.newImplicitScope());
          for (int i = 0; i < layout.elementCount().getAsLong(); i++) {
              INT_HANDLE.set(segment, (long) i, i);

@@ -98,36 +97,36 @@
          assertEquals(spliteratorSum.get(), expected);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testBadSpliteratorElementSizeTooBig() {
-         MemorySegment.ofArray(new byte[2]).spliterator(MemoryLayouts.JAVA_INT);
+         MemorySegment.ofArray(new byte[2]).spliterator(ValueLayout.JAVA_INT);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testBadStreamElementSizeTooBig() {
-         MemorySegment.ofArray(new byte[2]).elements(MemoryLayouts.JAVA_INT);
+         MemorySegment.ofArray(new byte[2]).elements(ValueLayout.JAVA_INT);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testBadSpliteratorElementSizeNotMultiple() {
-         MemorySegment.ofArray(new byte[7]).spliterator(MemoryLayouts.JAVA_INT);
+         MemorySegment.ofArray(new byte[7]).spliterator(ValueLayout.JAVA_INT);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testBadStreamElementSizeNotMultiple() {
-         MemorySegment.ofArray(new byte[7]).elements(MemoryLayouts.JAVA_INT);
+         MemorySegment.ofArray(new byte[7]).elements(ValueLayout.JAVA_INT);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testBadSpliteratorElementSizeZero() {
-         MemorySegment.ofArray(new byte[7]).spliterator(MemoryLayout.sequenceLayout(0, MemoryLayouts.JAVA_INT));
+         MemorySegment.ofArray(new byte[7]).spliterator(MemoryLayout.sequenceLayout(0, ValueLayout.JAVA_INT));
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testBadStreamElementSizeZero() {
-         MemorySegment.ofArray(new byte[7]).elements(MemoryLayout.sequenceLayout(0, MemoryLayouts.JAVA_INT));
+         MemorySegment.ofArray(new byte[7]).elements(MemoryLayout.sequenceLayout(0, ValueLayout.JAVA_INT));
      }
  
      static long sumSingle(long acc, MemorySegment segment) {
          return acc + (int)INT_HANDLE.get(segment, 0L);
      }
< prev index next >