Making native calls from the JVM

Tobi Ajila atobia at ca.ibm.com
Mon May 11 20:47:27 UTC 2015



Hi,

I'd like to start off discussions on native function calls from the JVM.
We've read (a slightly redacted version of) John Rose's paper, "Making
native calls from the JVM".  Using MethodHandles as the capability to call
native functions is a great idea.

While I like the MHs.nativeInvoker / Lookup.findNativeAddress APIs, we
should think long and hard before exposing the native entrypoints as raw
longs.  Apart from the obvious security issues touched on in the paper,
there are issues if the native library gets unloaded while a user still has
a long representing a function in that library.  The address either needs
to be embedded in the MH (which means no nativeInvoker api) or the address
needs to be wrapped in some kind of 'NativeFunction' Object so that library
unloading can invalidate the MH or NativeFunction.

Can you post an initial version (javadoc?) of the raw API?  It would be
valuable to have both JVMs prototyping the same API.

The document mentions an "options" string that describes arguments for
native calls.  Is this an implementation detail that describes how to
handle the wrapping / unwrapping of arguments and other calling sequence
details?  If this is something that describes the types, it seems to
overlap with the LDL discussions.  Can you provide some additional details
on the "options" string and its purpose?

Our current mental model is that the MHs would provide a better way to call
native functions while the LDL would describe the native arguments / return
types. There are a lot of details in how the two pieces interact that still
need to be worked out but this approach sounds promising.

Thanks
-Tobi


More information about the panama-spec-experts mailing list