< prev index next >

test/jdk/java/foreign/TestNULLAddress.java

Print this page
*** 32,41 ***
  
  import jdk.incubator.foreign.Addressable;
  import jdk.incubator.foreign.CLinker;
  import jdk.incubator.foreign.FunctionDescriptor;
  import jdk.incubator.foreign.MemoryAddress;
  import org.testng.annotations.Test;
  
  import java.lang.invoke.MethodHandle;
- import java.lang.invoke.MethodType;
- import java.nio.charset.Charset;
  
  public class TestNULLAddress {
  
!     static final CLinker LINKER = CLinker.getInstance();
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testNULLLinking() {
          LINKER.downcallHandle(
!                 MemoryAddress.NULL,
-                 MethodType.methodType(void.class),
                  FunctionDescriptor.ofVoid());
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testNULLVirtual() throws Throwable {
          MethodHandle mh = LINKER.downcallHandle(
-                 MethodType.methodType(void.class),
                  FunctionDescriptor.ofVoid());
!         mh.invokeExact((Addressable) MemoryAddress.NULL);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
!     public void testNULLtoJavaString() {
!         CLinker.toJavaString(MemoryAddress.NULL);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
!     public void testNULLfreeMemory() {
!         CLinker.freeMemory(MemoryAddress.NULL);
      }
  }
--- 32,39 ---
  
  import jdk.incubator.foreign.Addressable;
  import jdk.incubator.foreign.CLinker;
  import jdk.incubator.foreign.FunctionDescriptor;
  import jdk.incubator.foreign.MemoryAddress;
+ import jdk.incubator.foreign.NativeSymbol;
+ import jdk.incubator.foreign.ResourceScope;
  import org.testng.annotations.Test;
  
  import java.lang.invoke.MethodHandle;
  
  public class TestNULLAddress {
  
!     static final CLinker LINKER = CLinker.systemCLinker();
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testNULLLinking() {
          LINKER.downcallHandle(
!                 NativeSymbol.ofAddress("nullAddress", MemoryAddress.NULL, ResourceScope.globalScope()),
                  FunctionDescriptor.ofVoid());
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
      public void testNULLVirtual() throws Throwable {
          MethodHandle mh = LINKER.downcallHandle(
                  FunctionDescriptor.ofVoid());
!         mh.invokeExact(NativeSymbol.ofAddress("null", MemoryAddress.NULL, ResourceScope.globalScope()));
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
!     public void testNULLgetString() {
!         MemoryAddress.NULL.getUtf8String(0);
      }
  
      @Test(expectedExceptions = IllegalArgumentException.class)
!     public void testNULLsetString() {
!         MemoryAddress.NULL.setUtf8String(0, "hello");
      }
  }
< prev index next >