< prev index next >

test/jdk/java/foreign/TestSymbolLookup.java

Print this page
*** 26,17 ***
   * @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
   * @modules jdk.incubator.foreign/jdk.internal.foreign
   * @run testng/othervm --enable-native-access=ALL-UNNAMED TestSymbolLookup
   */
  
  import jdk.incubator.foreign.SymbolLookup;
- import jdk.incubator.foreign.MemoryAccess;
- import jdk.incubator.foreign.MemoryLayouts;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
  import org.testng.annotations.Test;
  
  import static org.testng.Assert.*;
  
  // FYI this test is run on 64-bit platforms only for now,
  // since the windows 32-bit linker fails and there
  // is some fallback behaviour to use the 64-bit linker,
--- 26,18 ---
   * @requires ((os.arch == "amd64" | os.arch == "x86_64") & sun.arch.data.model == "64") | os.arch == "aarch64"
   * @modules jdk.incubator.foreign/jdk.internal.foreign
   * @run testng/othervm --enable-native-access=ALL-UNNAMED TestSymbolLookup
   */
  
+ import jdk.incubator.foreign.MemoryAddress;
  import jdk.incubator.foreign.SymbolLookup;
  import jdk.incubator.foreign.MemorySegment;
  import jdk.incubator.foreign.ResourceScope;
+ import jdk.incubator.foreign.ValueLayout;
  import org.testng.annotations.Test;
  
+ import static jdk.incubator.foreign.ValueLayout.JAVA_BYTE;
  import static org.testng.Assert.*;
  
  // FYI this test is run on 64-bit platforms only for now,
  // since the windows 32-bit linker fails and there
  // is some fallback behaviour to use the 64-bit linker,

*** 59,9 ***
          assertTrue(LOOKUP.lookup("nonExistent").isEmpty());
      }
  
      @Test
      public void testVariableSymbolLookup() {
!         MemorySegment segment = LOOKUP.lookup("c").get().asSegment(MemoryLayouts.JAVA_INT.byteSize(), ResourceScope.globalScope());
!         assertEquals(MemoryAccess.getInt(segment), 42);
      }
  }
--- 60,9 ---
          assertTrue(LOOKUP.lookup("nonExistent").isEmpty());
      }
  
      @Test
      public void testVariableSymbolLookup() {
!         MemorySegment segment = MemorySegment.ofAddressNative(LOOKUP.lookup("c").get().address(), ValueLayout.JAVA_INT.byteSize(), ResourceScope.globalScope());
!         assertEquals(segment.get(JAVA_BYTE, 0), 42);
      }
  }
< prev index next >