Pointer/Scope API questions

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jan 7 17:56:56 UTC 2020


On 07/01/2020 17:11, Maurizio Cimadamore wrote:
> I remember your use case - if you have no header, jextract can't help 
> you much - it couldn't before, it will not be able to in the future.
>
> But let's not pretend this is the common case - what you are doing in 
> [1] is very very very specific. In 99.999999% cases, users do have 
> some headers to work with. In which cases jextract will use the info 
> from the header to generate all layouts, var handles, method handles, 
> and some static wrappers on top.

Sorry, I though your use case was the one you referred to previously 
where you needed to call native functions - but you had no header and 
you were just creating pointers out of thin air with given values (which 
you knew were the entry points of the library you wanted).

In such a desperate case, of course there's no tool that can save you - 
I hope we agree there.

If you do have an header - then jextract can generate bindings for the 
functions and variables in that header (plus accessors for the struct 
fields) - the libclang bindings included in the jextract API have been 
generated with a very raw version of the minimal jextract prototype:

http://hg.openjdk.java.net/panama/dev/file/e3e4b9767bfb/src/jdk.incubator.jextract/share/classes/jdk/internal/clang/libclang/Index_h.java

So, unless you are particularly keen on writing those 7K lines by hand, 
I'd say jextract has some useful role here ;-)

In other words, yes, you can define everything yourself - but this is 
often not practical unless (a) you are working with a very very small 
library or (ii) you know in advance that you need 1-2 functions of a 
biggie library. Even in those cases though, there is a risk you could 
get some information wrong, and introduce mistakes in the process.

Maurizio






More information about the panama-dev mailing list