< prev index next >

test/jdk/java/foreign/TestStringEncoding.java

Print this page
@@ -20,14 +20,14 @@
   *  or visit www.oracle.com if you need additional information or have any
   *  questions.
   *
   */
  
- import jdk.incubator.foreign.CLinker;
  import jdk.incubator.foreign.MemorySegment;
  
  import jdk.incubator.foreign.ResourceScope;
+ import jdk.incubator.foreign.SegmentAllocator;
  import org.testng.annotations.*;
  import static org.testng.Assert.*;
  
  /*
   * @test

@@ -38,15 +38,16 @@
  public class TestStringEncoding {
  
      @Test(dataProvider = "strings")
      public void testStrings(String testString, int expectedByteLength) {
          try (ResourceScope scope = ResourceScope.newConfinedScope()) {
-             MemorySegment text = CLinker.toCString(testString, scope);
+             SegmentAllocator allocator = SegmentAllocator.newNativeArena(expectedByteLength, scope);
+             MemorySegment text = allocator.allocateUtf8String(testString);
  
              assertEquals(text.byteSize(), expectedByteLength);
  
-             String roundTrip = CLinker.toJavaString(text);
+             String roundTrip = text.getUtf8String(0);
              assertEquals(roundTrip, testString);
          }
      }
  
      @DataProvider
< prev index next >