Ok, I've implemented heap Buffer arguments in V3. You can also do this
via a TypeMapper + ToNativeConverter.
That would be great. With this implemented, I think all the bases are
covered, namely:
- byte[] (VM pins or copies to give us a pointer)
- heap ByteBuffer (since ByteBuffer#array returns a byte[] which the VM
can pin or copy)
- direct ByteBuffer (pointer is available via a JNI call)
- float[] (VM pins or copies to give us a pointer)
- heap FloatBuffer (since FloatBuffer#array returns a float[] which the
VM can pin or copy)
- direct FloatBuffer (pointer is available via a JNI call)
AFAIK, there is no way to create nor access the pointer on a direct
FloatBuffer.
According to the javadoc, the only way they are created is via
asFloatBuffer() on a direct ByteBuffer - and I couldn't see anyway to
get back to the direct ByteBuffer from a FloatBuffer view.
That means something like this will throw an exception:
FloatBuffer fb = ByteBuffer.allocateDirect(1024).asFloatBuffer();
some_function(fb);
Its a pretty weird corner case, and there's nothing JNA can do about it.