static inline and jextract

Manuel Bleichenbacher manuel.bleichenbacher at gmail.com
Mon Sep 5 11:30:36 UTC 2022


Is there a reason to treat inline static functions different from
function-like macros?

Inline static functions are never exported. So if code is generated, it
will always fail. It would make much more sense to ignore them and not
generate code.

If code is generated, workarounds must be used. In particular, the function
and data structures must be explicitly specified. It is no longer possible
to use jextract for entire header files if just a single inline static
function is present.


On Mon, Sep 5, 2022 at 4:42 AM Sundararajan Athijegannathan <
sundararajan.athijegannathan at oracle.com> wrote:

> 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/1de2167a/attachment.htm>


More information about the jextract-dev mailing list