jextract generates downcallHandles where I need upcallStubs

Sebastian Stenzel sebastian.stenzel at gmail.com
Sat Dec 26 09:23:50 UTC 2020


> On 15. Dec 2020, at 12:31, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> Now, it's true that the function pointer type behind "readdir" takes its own function pointer (filler), but that shouldn't be a concern when creating the upcall for (1) - a function pointer is just some MemoryAddress parameter that the upcall receives (and that the runtime of the libfuse library will provide). And, it is true that, in this case jextract will also generate functional interfaces for e.g. the filler upcall, but you don't have to use them in this case (since the filler function pointer will never be generated by you - but by the library) - of course jextract sees a function pointer and generates the corresponding functional interface, it has no way to know which party will allocate the function pointer.

After experimenting with the latest snapshot version of Panama, I was now able to implement aforementioned readdir() method. However I still don't manage to use the filler function.

jextract will generate a Java method interface from readdir [1] that looks like this:

```
int readdir(MemoryAddress path, MemoryAddress buf, MemoryAddress filler, long offset, MemoryAddress fi)
```

Note that the filler is merely a MemoryAddress. From within my Java implementation I'd need to call filler, however in order to create a downcallHandle from this address, I'd need to know the FunctionDescriptor, which is kept package-private within the code generated by jextract.

It would be even easier, if there was some way to retrieve a MethodHandle from a given MemoryAddress and a known FunctionDescriptor.

Or am I missing something, again?


[1]: https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L304


More information about the panama-dev mailing list