Comments and replies from Ioannis Tsakpinis, of the LWJGL project:
> Just read the JEP, I think it's great and I don't have anything to add at
> this point. The only thing I found a bit odd was mention of (new?) native
> memory management. Which NIO's direct buffers basically is. Correct me if
> I'm wrong, but my guess is that you're talking about something lower-level
> (an official Unsafe?), something that could have been used together with the
> FFI to implement everything in NIO. And not the other way around, like my
> suggestion above to use direct buffers as a pointer abstraction in the FFI.
> Btw (you've probably seen this already) Oracle is already open to
> discussions about Unsafe:
>
https://blogs.oracle.com/dave/entry/do_you_use_sun_misc
Will have a look at that blog post.
WRT native memory, I agree that this isn't much more than direct
ByteBuffer in implementation. What JNA and JNR provide is a Java-level
abstraction atop that so you don't have to manually marshal values
to/from memory. So the JEP (and eventual JSR) would essentially make
it possible for user code to define a "super-ByteBuffer" that is
backed by native memory but knows about struct layout and value
marshaling (and perhaps lifecycle).
> Oh, a thought I just had. Should the JEP include something about callback
> functions? Right now that's a bit of a pain for us, callbacks from C to Java
> code is the only functionality we have to code manually in LWJGL. I know
> there's dynamic native code generation magic that can be used to handle this
> (JNA & JNR do it too iirc), but I wonder if there's a better way with a
> built-in FFI in the JVM. Threading issues exist here too, callbacks can
> either be synchronous (from a JVM thread) or asynchronous (from a native
> thread). Anyway, this isn't too important for us (not many callbacks to
> support), but it'd be nice to get rid of JNI completely.
I don't know if that's the level of detail we need to have in the JEP,
but it's a good thought. I also don't call out how call protocols
should work, how specific types should marshal. Callbacks may be a big
enough item to mention explicitly.