I get a bytebuffer
via the native methods.
The bytebuffer
starts with 3 int
s, then contains only doubles.
The third int<
In your posted code, you are calling this:
double * rest = (double *)env->GetDirectBufferAddress(bytebuffer + 12);
This adds 12 to the bytebuffer
jobject
, which not a number.
GetDirectBufferAddress()
returns an address; since the first 3 int
are 4 bytes each, I believe you are correctly adding 12, but you are not adding it in the right place.
What you probably meant to do is this:
double * rest = (double *)((char *)env->GetDirectBufferAddress(bytebuffer) + 12);
For your overall code, to get the initial three int
s and the remaining double
s, try something similar to this:
void * address = env->GetDirectBufferAddress(bytebuffer);
int * firstInt = (int *)address;
int * secondInt = (int *)address + 1;
int * doubleCount = (int *)address + 2;
double * rest = (double *)((char *)address + 3 * sizeof(int));
// you said the third int represents the number of doubles following
for (int i = 0; i < doubleCount; i++) {
double d = *rest + i; // or rest[i]
// do something with the d double
}