static inline and jextract
Sundararajan Athijegannathan
sundararajan.athijegannathan at oracle.com
Mon Sep 5 02:42:04 UTC 2022
Hi,
Only symbols exported from shared objects/DLLs/dylibs can be called (for eg. marked declspec(dllexport) on Windows, listed in mapfile on Unix platforms and so on). Using platform specific tools such as "nm" (Linux), "otool" (macOS) etc, you can check if that symbol is exported from the library.
Also, you need to load that native library using System.load/loadLibrary API before creating native method handles.
Hope this helps,
-Sundar
________________________________
From: jextract-dev <jextract-dev-retn at openjdk.org> on behalf of dreamlike_ocean lei <dreamlike.vertx at gmail.com>
Sent: 04 September 2022 20:00
To: jextract-dev at openjdk.org <jextract-dev at openjdk.org>
Subject: static inline and jextract
English is not my first language
I used jextract to generate a java-bound version of liburing.h.
I found an unreasonable situation。 such as:
`static inline void io_uring_prep_readv`
It is not an exported function,But jextract generates code like this
public static void io_uring_prep_readv(Addressable var0, int var1, Addressable var2, int var3, long var4)
when I call ` io_uring_prep_readv` in java, It will throw Exception in thread "main" java.lang.UnsatisfiedLinkError: unresolved symbol: io_uring_prep_readv
Isn't this unreasonable and inconvenient?Shouldn't only exported functions be generated?
――――――――Chinese version―――――――――――――
我利用jextract 生成liburing.h的java绑定
但是我发现了一个很奇怪的情况,像`static inline void io_uring_prep_readv`这种函数并不是导出的函数,但是jextract 确实生成了这个的java代码。
public static void io_uring_prep_readv(Addressable var0, int var1, Addressable var2, int var3, long var4)
当我调用用java去调用io_uring_prep_readv时,它会抛出一个Exception in thread "main" java.lang.UnsatisfiedLinkError: unresolved symbol: io_uring_prep_readv异常
这确实不太合理也不太方便吧,难道不应该只生成导出的函数吗?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jextract-dev/attachments/20220905/0296e340/attachment-0001.htm>
More information about the jextract-dev
mailing list