A
abhi147
Hi all ,
I am a newbie in JNI . I need to pass a two dimensional byte array
through JNI .
The snippet of JNI function is like this :
JNIEXPORT jstring JNICALL Java_com_test_invokeTest
(JNIEnv *env, jobject cl, jobjectArray detail)
{
int i ,nRows ;
jobject col;
char *Details[20];
nRows = (*env)->GetArrayLength(env, detail);
for (i = 0; i < nRows; i++)
{
col = (*env)->GetObjectArrayElement(env, detail, i);
Details = (*env)->GetCharArrayElements(env, col, NULL);
printf("Details[%d] : %s\n",i,Details);
}
for(i = 0; i < nRows; i++)
(*env)->ReleaseCharArrayElements(env, col, Details,NULL);
return ((*env)-> NewStringUTF(env,str));
}
When I am passing a 2-dimensional byte array and executing it without
any java flags , it works properly most of the time (occasionally it
was crashing the JVM ) . So I tried using flags "-Xcheck:jni -Xfuture"
as suggested by Sun . When I used this flags , it is giving me this
error
FATAL ERROR in native method: Array element type mismatch in JNI.
It's crashing just before the call Details =
(*env)->GetCharArrayElements(env, col, NULL);
Can anyone tell me what's wrong with this call .. or should I use some
other call ?
Thanks a lot of your help !
I am a newbie in JNI . I need to pass a two dimensional byte array
through JNI .
The snippet of JNI function is like this :
JNIEXPORT jstring JNICALL Java_com_test_invokeTest
(JNIEnv *env, jobject cl, jobjectArray detail)
{
int i ,nRows ;
jobject col;
char *Details[20];
nRows = (*env)->GetArrayLength(env, detail);
for (i = 0; i < nRows; i++)
{
col = (*env)->GetObjectArrayElement(env, detail, i);
Details = (*env)->GetCharArrayElements(env, col, NULL);
printf("Details[%d] : %s\n",i,Details);
}
for(i = 0; i < nRows; i++)
(*env)->ReleaseCharArrayElements(env, col, Details,NULL);
return ((*env)-> NewStringUTF(env,str));
}
When I am passing a 2-dimensional byte array and executing it without
any java flags , it works properly most of the time (occasionally it
was crashing the JVM ) . So I tried using flags "-Xcheck:jni -Xfuture"
as suggested by Sun . When I used this flags , it is giving me this
error
FATAL ERROR in native method: Array element type mismatch in JNI.
It's crashing just before the call Details =
(*env)->GetCharArrayElements(env, col, NULL);
Can anyone tell me what's wrong with this call .. or should I use some
other call ?
Thanks a lot of your help !