I have a JNI library which accepts a DirectByteBuffer and operates over it.
To get the buffer address, I was using:
(unsigned char *) env->GetDirectBufferAddress(input)
That was good, but after profiling it I noticed that a long time was spent in jni_IsInstanceOf:
I then replaced it with direct access to Buffer.address
java_nio_Buffer = env->FindClass("java/nio/Buffer");
java_nio_Buffer_address = env->GetFieldID(java_nio_Buffer, "address", "J");
(...)
(unsigned char *) env->GetLongField(input, java_nio_Buffer_address)
That caused a huge speedup in that code.
Are there any major risks in getting a DirectByteBuffer address that way, given I know my object will always be a DirectByteBuffer?
