开发者

JNI methods modifying pointers

Having a peculiar problem. When I call the following JNI method.

jobjectArray array = env->NewObjectArray(list->size, jcla开发者_如何学JAVAss, 0);

Now, list->size is set to 54. But as soon as the code above is run the same pointer returns, 2405015736 whats going on? As affects the values held in the rest of the struct also. Setting a static value i.e.

jobjectArray array = env->NewObjectArray(54, jclass, 0)

Also has no effect. Any ideas? I'm stumped.

(jclass is a loaded class object jclass = env->FindClass("name"); )

Thanks


Your problem is that size may not be of 'jsize' type so conversion has to take place. Now, this would be all well and good, but JNI is an absolute pain with this stuff. I think what is happening is that your stack is getting corrupted from a number which is interpreted as being too big. Or something like that. Just do the size conversion like so:

jint msize = list->size;
jobjectArray array = env->NewObjectArray(msize, jclass, 0);

This should do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜