< prev index next >


Print this page
@@ -32,28 +32,28 @@
  import java.util.Objects;
  import java.util.Optional;
   * A symbol lookup. Exposes a lookup operation for searching symbol addresses by name, see {@link SymbolLookup#lookup(String)}.
-  * A symbol lookup can be used to lookup a symbol in a loaded library. Clients can obtain a {@linkplain #loaderLookup() loader lookup},
+  * A symbol lookup can be used to look up a symbol in a loaded library. Clients can obtain a {@linkplain #loaderLookup() loader lookup},
   * which can be used to search symbols in libraries loaded by the current classloader (e.g. using {@link System#load(String)},
   * or {@link System#loadLibrary(String)}).
-  * Alternatively, clients can obtain a {@linkplain CLinker#systemLookup() platform-dependent lookup}, to search symbols
-  * in the standard C library.
+  * Alternatively, clients can search symbols in the standard C library using a {@link CLinker}, which conveniently
+  * implements this interface.
   * <p> Unless otherwise specified, passing a {@code null} argument, or an array argument containing one or more {@code null}
   * elements to a method in this class causes a {@link NullPointerException NullPointerException} to be thrown. </p>
  public interface SymbolLookup {
       * Looks up a symbol with given name in this lookup.
       * @param name the symbol name.
-      * @return the memory address associated with the symbol (if any).
+      * @return the lookup symbol (if any).
-     Optional<MemoryAddress> lookup(String name);
+     Optional<NativeSymbol> lookup(String name);
       * Obtains a symbol lookup suitable to find symbols in native libraries associated with the caller's classloader
       * (that is, libraries loaded using {@link System#loadLibrary} or {@link System#load}).
       * <p>

@@ -74,9 +74,10 @@
          ClassLoader loader = Objects.requireNonNull(caller.getClassLoader());
          return name -> {
              JavaLangAccess javaLangAccess = SharedSecrets.getJavaLangAccess();
              MemoryAddress addr = MemoryAddress.ofLong(javaLangAccess.findNative(loader, name));
-             return addr == MemoryAddress.NULL? Optional.empty() : Optional.of(addr);
+             return addr == MemoryAddress.NULL? Optional.empty() : Optional.of(NativeSymbol.ofAddress(name, addr, ResourceScope.globalScope()));
< prev index next >