< prev index next >

test/jdk/java/foreign/channels/TestAsyncSocketChannels.java

Print this page
@@ -46,16 +46,17 @@
  import java.util.concurrent.Future;
  import java.util.concurrent.atomic.AtomicBoolean;
  import java.util.concurrent.atomic.AtomicInteger;
  import java.util.concurrent.atomic.AtomicLong;
  import java.util.function.Supplier;
- import jdk.incubator.foreign.MemoryAccess;
+ 
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import org.testng.annotations.*;
  import static java.lang.System.out;
  import static java.util.concurrent.TimeUnit.SECONDS;
+ import static jdk.incubator.foreign.ValueLayout.JAVA_BYTE;
  import static org.testng.Assert.*;
  
  /**
   * Tests consisting of buffer views with asynchronous NIO network channels.
   */

@@ -160,11 +161,11 @@
               var asc2 = connectChannels(assc, asc1);
               var scp = closeableScopeOrNull(scope = scopeSupplier.get())) {
              MemorySegment segment1 = MemorySegment.allocateNative(10, 1, scope);
              MemorySegment segment2 = MemorySegment.allocateNative(10, 1, scope);
              for (int i = 0; i < 10; i++) {
-                 MemoryAccess.setByteAtOffset(segment1, i, (byte) i);
+                 segment1.set(JAVA_BYTE, i, (byte) i);
              }
              {   // Future variants
                  ByteBuffer bb1 = segment1.asByteBuffer();
                  ByteBuffer bb2 = segment2.asByteBuffer();
                  assertEquals((int)asc1.write(bb1).get(), 10);

@@ -219,11 +220,11 @@
                  out.println("testCloseWithOutstandingRead - op");
                  var handler = new TestHandler<Long>();
                  ioOp.accept(handler);
                  assertFalse(handler.isDone());
                  assertTrue(scope.isAlive());
-                 assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is acquired by");
+                 assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is kept alive by");
  
                  // write to allow the blocking read complete, which will
                  // in turn unlock the scope and allow it to be closed.
                  asc2.write(ByteBuffer.wrap(new byte[] { 0x01 })).get();
                  handler.await().assertCompleteWith(1L);

@@ -268,11 +269,11 @@
                          }
                      }));
              // give time for socket buffer to fill up.
              awaitNoFurtherWrites(bytesWritten);
  
-             assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is acquired by");
+             assertMessage(expectThrows(ISE, () -> scope.close()), "Scope is kept alive by");
              assertTrue(scope.isAlive());
  
              // signal handler to stop further writing
              continueWriting.set(false);
  
< prev index next >