New candidate JEP: 370: Foreign-Memory Access API

David Lloyd david.lloyd at redhat.com
Wed Nov 27 14:04:38 UTC 2019


On Mon, Nov 25, 2019 at 11:28 AM <mark.reinhold at oracle.com> wrote:
>
> https://openjdk.java.net/jeps/370

One more question!  Well, two I guess.

First, in the interim before Panama or something like it comes to the
main project, will it be possible to pass MemoryAddress kinds of
things to JNI methods (to replace the current "pattern" of sticking
pointer values into `long` fields)?  Could the JNI API be extended for
this purpose?

Second, what about an API to allocate memory from the stack?  This is
really useful in GraalVM (granted they have a sort-of-Panama-ish way
of calling C functions already, and they're really quite "loose" when
it comes to safety in some regards) and could simplify some things
already, particularly if the pointer could then be passed to a JNI
method.  Given the sensitive nature of stack allocation you'd probably
have to add some extra checks (like checking that the thread matches
on each access and that it is in scope, and you'd probably have to do
the latter via callback like StackWalker does) but it would be pretty
useful nonetheless.
-- 
- DML



More information about the core-libs-dev mailing list