Native method binding

Yasumasa Suenaga suenaga at oss.nttdata.com
Wed Dec 18 00:13:28 UTC 2024


Hi,

I think good idea to add a feature of FFM over JNI because it can reduce overheads relates to MethodHandle, and we can leverage IDE power (code suggestion, etc).

I implemented similar feature on my ffmasm [1].
It binds MemorySegment (for function pointer) to native method, so it shouldn't make difference for calling overhead with normal JNI call, and also we can get help on IDE.


Thanks,

Yasumasa


[1] https://github.com/YaSuenag/ffmasm?tab=readme-ov-file#play-with-jni

On 2024/12/18 2:12, David Lloyd wrote:
> With the (hopeful) ascendance of FFM over JNI, what about the idea of allowing `native` methods to be bound to `MethodHandle`s on the Java side at run time? This would allow for a much nicer experience than creating wrapper methods and would bring another level of parity with JNI, which has this capability (`RegisterNatives`). The capability could be restricted as a form of native access, and only allowed for methods in classes within the same module.
> 
> What do you think?
> 
> -- 
> - DML • he/him



More information about the panama-dev mailing list