System.loadLibrary and CLinker.lookup exception

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Apr 27 10:01:51 UTC 2022


On 27/04/2022 10:50, Jack Andrews wrote:
> On Wed, 27 Apr 2022 at 18:35, Maurizio Cimadamore 
> <maurizio.cimadamore at oracle.com> wrote:
>
>     The way to search library symbols in Panama is via a SymbolLookup.
>
>
> this could be communicated in sample code. eg. at
> https://github.com/openjdk/panama-foreign/blob/foreign-jextract/doc/panama_ffi.md 
> <https://urldefense.com/v3/__https://github.com/openjdk/panama-foreign/blob/foreign-jextract/doc/panama_ffi.md__;!!ACWV5N9M2RV99hQ!IW3UmEGl2MLGIHZQZu1an-gsdZ8i9XMt0thBpF0y3jowv0r9xgBGT96wF6ZpWjewf8zCaY7Yg1Vkj8En2j1u45k$>
> with demonstrations of (2) rather than the demonstration of (3).
> thinking like the user with some extensive sample code could benefit 
> the project.

Sure, documentation could be improved (and the document you refers to 
the Java 18 API).

If you have ideas on how to improve the documentation, please file a PR.

>
>     2) libraryLookup(Path/String): this loads a library, searches
>     symbols in
>     it. When the associated scope is closed, the library is unloaded.
>     Allows
>     same library to be loaded in multiple loaders.
>
>     3) system lookup - this is currently exposed by CLinker itself, which
>     implements SymbolLookup. The idea behind this being an instance
>     method
>     in CLinker is that different linkers might expose different
>     "standard"
>     libraries.
>
>
> how does the user benefit from (3)? by having memcpy on hand?

Yes, that's the idea. (3) gives you access to the usual C libraries. On 
Linux, this can be mostly achieved by creating a library lookup for 
"libc.so.6" - but on Windows things are more complicated, so we wanted 
to give some easy access to standard functions.

Maurizio


More information about the panama-dev mailing list