Some small feedback regading jextract as a user

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Nov 12 21:23:07 UTC 2020


Hi, thanks for the feedback, some responses inline below

On 12/11/2020 20:47, Jerven Tjalling Bolleman wrote:
> Dear panama-devs,
>
> I hope this feedback is in the useful category. My feedback is 
> regarding the jextract tool and ffi. Most of it is trivial but I hope 
> it is still useful.
>
> No --version or -v option to quickly get the exact version of jextract 
> (would make future feedback easier to pinpoint).
Sure - right now it's all very "bleeding edge" but this is definitively 
something to consider.
>
> Assume the jextract user has minimal or no knowledge (like me) of how 
> the library they want to wrap was built. For example the first error I 
> ran into was “fatal error: 'cstdarg' file not found” which required 
> “-C -x -C c++” to be added to the command. This was not intuitive and 
> certainly not the first thing I tried (I started with trying different 
> -I combinations. Specifically, I am trying to wrap a rust library with 
> a header generated by rust cbindgen. So thinking of needing to add 
> clang options to jextract was not high on my lists of things to do.
Would be interesting and useful to know which libraries did you try to 
extract
>
> Having fixed that I ran into a null pointer exception. i.e.
> WARNING: Using incubator modules: jdk.incubator.jextract, 
> jdk.incubator.foreign
> java.lang.NullPointerException
Did you get the NPE at extraction time, or at runtime?
>
> While we might dislike stack traces. I think a bug report (to myself 
> regarding the C code) or to you would be easier to work on when you 
> have a stack trace.
>
> When generating the helloworld example I needed to compile with -fPIC. 
> Which the document at
> https://github.com/openjdk/panama-foreign/blob/foreign-jextract/doc/panama_jextract.md#jextract-a-jar-file-for-helloworldh 
> claims generates a jar file but actually generates a directory with 
> class files. The example worked fine with clang 10.0.1 but my fedora 
> 10.2.1 gcc needed -fPIC.
Yep - gcc needs fPIC - I believe most of the guide is MacOS oriented, we 
need to improve that and add other platforms/compilers.
>
> Regarding the FFI interface, I would love to see more examples 
> regarding the group layout functionality.
I believe the tensorflow example has some structs being used - but 
perhaps this is not what you meant?
>
> Otherwise with jextract I quite quickly ran into error: unknown type 
> name without much of a suggestion why a certain type was not known. 
> The libraries added to the command line should have had the types. And 
> I am still working on this one.
To be able to help we need (a) the header you were trying to extract and 
(b) the exact exception you are getting. It seems like you are hitting a 
bug of some sorts, so it's defo worth looking into it.
>
> That said the tools have lots of promise and please keep working on them!

Thanks for giving jextract a try!

Maurizio

>
> Regards,
> Jerven
>
>
>
>


More information about the panama-dev mailing list