Re:How to Use the Foreign Function API in Java 22 to Call C ...
by chii on Wednesday May 08, 2024 @08:40PM
(#40304140)
> extracting it to a tmp file
i wonder if there's a way to do this entirely in memory? Because some deployment scenarios might not have disk space at all.
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by MobiusHorizons on Wednesday May 08, 2024 @08:52PM
(#40304199)
/tmp is often a RAM disk in such cases
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by xxs on Thursday May 09, 2024 @01:34AM
(#40305566)
not with java - it needs a path. Of course if you have a ram disk (e.g. /tmp) it'd do the job.
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by rwmj on Thursday May 09, 2024 @07:45AM
(#40307193)
Technically memfd_create will let you create a file descriptor backed by a memory region. However in Linux I don't believe there's a way to dlopen that. (Maybe dlopen /dev/fd/... might work?) In FreeBSD there's a fdlopen library function.
Edit: glibc proposal which was never accepted: https://sourceware.org/bugzilla/show_bug.cgi?id=11767
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by sedro on Wednesday May 08, 2024 @08:54PM
(#40304213)
You would also need to learn about Maven profiles and activation. And for other build tools, you'll be delighted to know they have partial support.
Re:How to Use the Foreign Function API in Java 22 to Call C ...
by xxs on Thursday May 09, 2024 @01:28AM
(#40305539)
>exract it to a tmp file that will be deleted on exit,
actually you delete it immediately (after load) on anything that's not windows... even then but it's likely to return false.
deleteOnExit just stores the path to delete and uses a shutdownHook to actually call delete. Nothing really special about it
I’ve met many perfectly reasonable developers who do know all those steps can be done but can’t put them all together - maybe because it just hasn’t clicked that you can store a library in a jar. It feels like something tutorials should cover, but I think falls into the, “surely everyone can work it out?” category.