< prev index next >

test/jdk/java/foreign/handles/lookup_module/handle/lookup/MethodHandleLookup.java

Print this page
*** 21,28 ***
   * questions.
   */
  
  package handle.lookup;
  
- import jdk.incubator.foreign.Addressable;
  import jdk.incubator.foreign.CLinker;
  
  import java.lang.invoke.MethodHandle;
  import java.lang.invoke.MethodHandles;
  import java.lang.invoke.MethodType;
- import java.nio.charset.Charset;
- import java.nio.file.Path;
- import java.util.Optional;
  
! import jdk.incubator.foreign.FunctionDescriptor;
  import jdk.incubator.foreign.SymbolLookup;
  import jdk.incubator.foreign.MemoryAddress;
- import jdk.incubator.foreign.MemoryLayout;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
- import jdk.incubator.foreign.SegmentAllocator;
  
  import org.testng.annotations.*;
  
  public class MethodHandleLookup {
  
      @Test(dataProvider = "restrictedMethods")
--- 21,24 ---
   * questions.
   */
  
  package handle.lookup;
  
  import jdk.incubator.foreign.CLinker;
  
  import java.lang.invoke.MethodHandle;
  import java.lang.invoke.MethodHandles;
  import java.lang.invoke.MethodType;
  
! import jdk.incubator.foreign.Addressable;
  import jdk.incubator.foreign.SymbolLookup;
  import jdk.incubator.foreign.MemoryAddress;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  
+ import jdk.incubator.foreign.VaList;
+ import jdk.incubator.foreign.ValueLayout;
  import org.testng.annotations.*;
  
  public class MethodHandleLookup {
  
      @Test(dataProvider = "restrictedMethods")

*** 52,42 ***
  
      @DataProvider(name = "restrictedMethods")
      static Object[][] restrictedMethods() {
          try {
              return new Object[][]{
!                     { MethodHandles.lookup().findStatic(CLinker.class, "getInstance",
!                             MethodType.methodType(CLinker.class)), "CLinker::getInstance" },
!                     { MethodHandles.lookup().findStatic(CLinker.class, "toJavaString",
!                             MethodType.methodType(String.class, MemoryAddress.class)),
-                             "CLinker::toJavaString" },
-                     { MethodHandles.lookup().findStatic(CLinker.class, "allocateMemory",
-                             MethodType.methodType(MemoryAddress.class, long.class)),
-                             "CLinker::allocateMemory" },
-                     { MethodHandles.lookup().findStatic(CLinker.class, "freeMemory",
-                             MethodType.methodType(void.class, MemoryAddress.class)),
-                             "CLinker::freeMemory" },
-                     { MethodHandles.lookup().findStatic(CLinker.VaList.class, "ofAddress",
-                             MethodType.methodType(CLinker.VaList.class, MemoryAddress.class)),
                              "VaList::ofAddress/1" },
-                     { MethodHandles.lookup().findStatic(CLinker.VaList.class, "ofAddress",
-                             MethodType.methodType(CLinker.VaList.class, MemoryAddress.class, ResourceScope.class)),
-                             "VaList::ofAddress/2" },
-                     { MethodHandles.lookup().findStatic(CLinker.class, "systemLookup",
-                             MethodType.methodType(SymbolLookup.class)),
-                             "CLinker::systemLookup" },
                      { MethodHandles.lookup().findStatic(SymbolLookup.class, "loaderLookup",
                              MethodType.methodType(SymbolLookup.class)),
                              "SymbolLookup::loaderLookup" },
!                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "asSegment",
!                             MethodType.methodType(MemorySegment.class, long.class, ResourceScope.class)),
!                             "MemoryAddress::asSegment/1" },
!                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "asSegment",
!                             MethodType.methodType(MemorySegment.class, long.class, Runnable.class, ResourceScope.class)),
!                             "MemoryAddress::asSegment/2" },
!                     { MethodHandles.lookup().findStatic(MemorySegment.class, "globalNativeSegment",
!                             MethodType.methodType(MemorySegment.class)),
!                             "MemoryAddress::globalNativeSegment" }
              };
          } catch (Throwable ex) {
              throw new ExceptionInInitializerError((ex));
          }
      }
--- 48,81 ---
  
      @DataProvider(name = "restrictedMethods")
      static Object[][] restrictedMethods() {
          try {
              return new Object[][]{
!                     { MethodHandles.lookup().findStatic(CLinker.class, "systemCLinker",
!                             MethodType.methodType(CLinker.class)), "ForeignLinker::systemCLinker" },
!                     { MethodHandles.lookup().findStatic(VaList.class, "ofAddress",
!                             MethodType.methodType(VaList.class, MemoryAddress.class, ResourceScope.class)),
                              "VaList::ofAddress/1" },
                      { MethodHandles.lookup().findStatic(SymbolLookup.class, "loaderLookup",
                              MethodType.methodType(SymbolLookup.class)),
                              "SymbolLookup::loaderLookup" },
!                     { MethodHandles.lookup().findStatic(MemorySegment.class, "ofAddressNative",
!                             MethodType.methodType(MemorySegment.class, MemoryAddress.class, long.class, ResourceScope.class)),
!                             "MemorySegment::ofAddressNative" },
!                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "getUtf8String",
!                             MethodType.methodType(String.class, long.class)),
!                             "MemoryAddress::getUtf8String" },
!                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "setUtf8String",
!                             MethodType.methodType(void.class, long.class, String.class)),
!                             "MemoryAddress::setUtf8String" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(byte.class, ValueLayout.OfByte.class, long.class)),
+                             "MemoryAddress::get/byte" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(boolean.class, ValueLayout.OfBoolean.class, long.class)),
+                             "MemoryAddress::get/boolean" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(char.class, ValueLayout.OfChar.class, long.class)),
+                             "MemoryAddress::get/char" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(short.class, ValueLayout.OfShort.class, long.class)),
+                             "MemoryAddress::get/short" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(int.class, ValueLayout.OfInt.class, long.class)),
+                             "MemoryAddress::get/int" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(float.class, ValueLayout.OfFloat.class, long.class)),
+                             "MemoryAddress::get/float" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(long.class, ValueLayout.OfLong.class, long.class)),
+                             "MemoryAddress::get/long" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(double.class, ValueLayout.OfDouble.class, long.class)),
+                             "MemoryAddress::get/double" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "get",
+                             MethodType.methodType(MemoryAddress.class, ValueLayout.OfAddress.class, long.class)),
+                             "MemoryAddress::get/address" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfByte.class, long.class, byte.class)),
+                             "MemoryAddress::set/byte" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfBoolean.class, long.class, boolean.class)),
+                             "MemoryAddress::set/boolean" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfChar.class, long.class, char.class)),
+                             "MemoryAddress::set/char" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfShort.class, long.class, short.class)),
+                             "MemoryAddress::set/short" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfInt.class, long.class, int.class)),
+                             "MemoryAddress::set/int" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfFloat.class, long.class, float.class)),
+                             "MemoryAddress::set/float" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfLong.class, long.class, long.class)),
+                             "MemoryAddress::set/long" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfDouble.class, long.class, double.class)),
+                             "MemoryAddress::set/double" },
+                     { MethodHandles.lookup().findVirtual(MemoryAddress.class, "set",
+                             MethodType.methodType(void.class, ValueLayout.OfAddress.class, long.class, Addressable.class)),
+                             "MemoryAddress::set/address" },
              };
          } catch (Throwable ex) {
              throw new ExceptionInInitializerError((ex));
          }
      }
< prev index next >