SymbolLookup is a preview API of the Java platform.
Programs can only use SymbolLookup when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A symbol lookup isanobjectthatmaybeusedtoretrieveretrieves the address of a symbol in one or more libraries. A symbol is a named entity, such as a function or a global variable.
A symbol lookup is created with respect to a particular library (or libraries). Subsequently, the lookupfind(String) method takes the name of a symbol and returns the address of the symbol in that library.
The address of a symbol is modelled as a zero-length memory segment PREVIEW. The segment can be used in different ways:
It can be passed to a LinkerPREVIEW to create a downcall method handle, which can then be used to call the foreign function at the segment's baseaddress.
If a library was previously loaded through JNI, i.e., by System.load(String) or System.loadLibrary(String), then the library was also associated with a particular class loader. The factory method loaderLookup() creates a symbol lookup for all the libraries associated with the caller's class loader:
This symbol lookup, which is known as a loader lookup , is dynamic with respect to the libraries associated with the class loader. If other libraries are subsequently loaded through JNI and associated with the class loader, then the loader lookup will expose their symbols automatically.
Note that a loader lookup only exposes symbols in libraries that were previously loaded through JNI, i.e., by System.load(String) or System.loadLibrary(String). A loader lookup does not expose symbols in libraries that were loaded in the course of creating a library lookup:
Note also that a library lookup for library L exposes symbols in L even if L was previously loaded through JNI (the association with a class loader is immaterial to the library lookup):
System.loadLibrary("GL"); // libGL.so loaded here
libraryLookup("libGL.so", sessionscope).lookupfind("glGetString").isPresent(); // true
Finally, each LinkerPREVIEW provides a symbol lookup for libraries that are commonly used on the OS and processor combination supported by that LinkerPREVIEW. This symbol lookup, which is known as a default lookup , helps clients to quickly find addresses of well-known symbols. For example, a LinkerPREVIEW for Linux/x64 might choose to expose symbols in libc through the default lookup:
SymbolLookup is a preview API of the Java platform.
Programs can only use SymbolLookup when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A symbol lookup is an object that may be used to retrieve the address of a symbol in one or more libraries. A symbol is a named entity, such as a function or a global variable.
A symbol lookup is created with respect to a particular library (or libraries). Subsequently, the lookup(String) method takes the name of a symbol and returns the address of the symbol in that library.
The address of a symbol is modelled as a zero-length memory segment PREVIEW. The segment can be used in different ways:
It can be passed to a LinkerPREVIEW to create a downcall method handle, which can then be used to call the foreign function at the segment's base address.
If a library was previously loaded through JNI, i.e., by System.load(String) or System.loadLibrary(String), then the library was also associated with a particular class loader. The factory method loaderLookup() creates a symbol lookup for all the libraries associated with the caller's class loader:
This symbol lookup, which is known as a loader lookup , is dynamic with respect to the libraries associated with the class loader. If other libraries are subsequently loaded through JNI and associated with the class loader, then the loader lookup will expose their symbols automatically.
Note that a loader lookup only exposes symbols in libraries that were previously loaded through JNI, i.e., by System.load(String) or System.loadLibrary(String). A loader lookup does not expose symbols in libraries that were loaded in the course of creating a library lookup:
Note also that a library lookup for library L exposes symbols in L even if L was previously loaded through JNI (the association with a class loader is immaterial to the library lookup):
System.loadLibrary("GL"); // libGL.so loaded here
libraryLookup("libGL.so", session).lookup("glGetString").isPresent(); // true
Finally, each LinkerPREVIEW provides a symbol lookup for libraries that are commonly used on the OS and processor combination supported by that LinkerPREVIEW. This symbol lookup, which is known as a default lookup , helps clients to quickly find addresses of well-known symbols. For example, a LinkerPREVIEW for Linux/x64 might choose to expose symbols in libc through the default lookup:
SymbolLookup is a preview API of the Java platform.
Programs can only use SymbolLookup when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A symbol lookup retrieves the address of a symbol in one or more libraries. A symbol is a named entity, such as a function or a global variable.
A symbol lookup is created with respect to a particular library (or libraries). Subsequently, the find(String) method takes the name of a symbol and returns the address of the symbol in that library.
The address of a symbol is modelled as a zero-length memory segment PREVIEW. The segment can be used in different ways:
It can be passed to a LinkerPREVIEW to create a downcall method handle, which can then be used to call the foreign function at the segment's address.
If a library was previously loaded through JNI, i.e., by System.load(String) or System.loadLibrary(String), then the library was also associated with a particular class loader. The factory method loaderLookup() creates a symbol lookup for all the libraries associated with the caller's class loader:
This symbol lookup, which is known as a loader lookup , is dynamic with respect to the libraries associated with the class loader. If other libraries are subsequently loaded through JNI and associated with the class loader, then the loader lookup will expose their symbols automatically.
Note that a loader lookup only exposes symbols in libraries that were previously loaded through JNI, i.e., by System.load(String) or System.loadLibrary(String). A loader lookup does not expose symbols in libraries that were loaded in the course of creating a library lookup:
Note also that a library lookup for library L exposes symbols in L even if L was previously loaded through JNI (the association with a class loader is immaterial to the library lookup):
System.loadLibrary("GL"); // libGL.so loaded here
libraryLookup("libGL.so", scope).find("glGetString").isPresent(); // true
Finally, each LinkerPREVIEW provides a symbol lookup for libraries that are commonly used on the OS and processor combination supported by that LinkerPREVIEW. This symbol lookup, which is known as a default lookup , helps clients to quickly find addresses of well-known symbols. For example, a LinkerPREVIEW for Linux/x64 might choose to expose symbols in libc through the default lookup:
Returns a symbol lookup for symbols in the libraries associated with the caller's class loader.
A library is associated with a class loader CL when the library is loaded via an invocation of System.load(String) or System.loadLibrary(String) from code in a class defined by CL. If that code makes further invocations of System.load(String) or System.loadLibrary(String), then more libraries are loaded and associated with CL. The symbol lookup returned by this method is always current: it reflects all the libraries associated with the relevant class loader, even if they were loaded after this method returned.
Libraries associated with a class loader are unloaded when the class loader becomes unreachable. The symbol lookup returned by this method is backed by a non-closeablePREVIEW,sharedmemorysessionscopethatisalwaysaliveand which keeps the caller's class loader reachable. Therefore, libraries associated with the caller's class loader are kept loaded (and their symbols available) as long as a loader lookup for that class loader is reachable.
In cases where this method is called from a context where there is no caller frame on the stack (e.g. when called directly from a JNI attached thread), the caller's class loader defaults to the system class loader .
Returns:
a symbol lookup for symbols in the libraries associated with the caller's class loader.
Returns a symbol lookup for symbols in the libraries associated with the caller's class loader.
A library is associated with a class loader CL when the library is loaded via an invocation of System.load(String) or System.loadLibrary(String) from code in a class defined by CL. If that code makes further invocations of System.load(String) or System.loadLibrary(String), then more libraries are loaded and associated with CL. The symbol lookup returned by this method is always current: it reflects all the libraries associated with the relevant class loader, even if they were loaded after this method returned.
Libraries associated with a class loader are unloaded when the class loader becomes unreachable. The symbol lookup returned by this method is backed by a non-closeablePREVIEW, shared memory session which keeps the caller's class loader reachable. Therefore, libraries associated with the caller's class loader are kept loaded (and their symbols available) as long as a loader lookup for that class loader is reachable.
In cases where this method is called from a context where there is no caller frame on the stack (e.g. when called directly from a JNI attached thread), the caller's class loader defaults to the system class loader .
Returns:
a symbol lookup for symbols in the libraries associated with the caller's class loader.
Returns a symbol lookup for symbols in the libraries associated with the caller's class loader.
A library is associated with a class loader CL when the library is loaded via an invocation of System.load(String) or System.loadLibrary(String) from code in a class defined by CL. If that code makes further invocations of System.load(String) or System.loadLibrary(String), then more libraries are loaded and associated with CL. The symbol lookup returned by this method is always current: it reflects all the libraries associated with the relevant class loader, even if they were loaded after this method returned.
Libraries associated with a class loader are unloaded when the class loader becomes unreachable. The symbol lookup returned by this method is backed by a scope that is always alive and which keeps the caller's class loader reachable. Therefore, libraries associated with the caller's class loader are kept loaded (and their symbols available) as long as a loader lookup for that class loader is reachable.
In cases where this method is called from a context where there is no caller frame on the stack (e.g. when called directly from a JNI attached thread), the caller's class loader defaults to the system class loader .
Returns:
a symbol lookup for symbols in the libraries associated with the caller's class loader.
SymbolLookupwhen preview features are enabled.