some thoughts on panama/jextract

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jan 7 10:50:36 UTC 2020


On 07/01/2020 04:24, Michael Zucchi wrote:
> I think most of my initial concerns have been addressed so I will work 
> on porting some of my code and am interested to see how it works in 
> practice.  (but no jextract for now!) 

Thanks - I've took a look at your APIs and, since they look generally 
clean and high-level - I believe they can relatively easily be ported to 
use the MemoryAddress/MethodHandle machinery in the foreign-abi branch.

Without an extractor you will have to write some mechanical code by hand 
though - some examples of how to do that:

http://hg.openjdk.java.net/panama/dev/file/foreign-abi/test/jdk/java/foreign/StdLibTest.java

I believe you can use the same approach to implement your library 
without using JNI. I see you have many 'wrappers' with a 'long' address 
field - you will have to replace them with a MemoryAddress field (if 
these structs are to be passed by pointer - or MemorySegment if you want 
to pass them by value). Then you have to setup the required method 
handles to be able to call the native functions you want.

Cheers
Maurizio



More information about the panama-dev mailing list