Question about Linker.Option.isTrivial()

刘希晨 benrush0705 at gmail.com
Fri Jan 12 16:28:14 UTC 2024


Hi I want to ask a question about using project-panama, I implemented a
network library using JDK21 with panama-foreign and the performance are
quite well, since the API will officially release in JDK22, I started to
migrating my project to using JDK22-ea, and I have a question about using
Linker.Option.isTrivial(), I noticed that in JDK22 it seems to be renamed
as Linker.Option.critical(), the javadoc says the function should have an
extremely short running time in all cases, and does not callback into Java.
I am pretty sure that it could be used on some functions returning
constants macro from C, but in some cases, I am not quite sure if this
option could be used, here are some examples:

1. calling malloc() and free(), or some other API like epoll_create() and
epoll_ctl()
2. calling send() and recv() on non-blocking sockets
3. just assigning some values to the target structs in C functions

They all have a very short running time, and they do not callback into
Java, I have tested using Linker.Option.isTrivial() and they all went well,
but I am still not very sure about my usage here, since I don't quite
understand what Linker.Option.isTrivial() did under the hood, so I want to
seek some suggestions from experts here.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240113/c1126d79/attachment.htm>


More information about the panama-dev mailing list