如果我使用内存地址和存储在该地址的数据类型调用本机方法,如何在JNI中创建指向该地址的指针?
在Java中:
pointers(long.class, 810234092817);
在JNI:
JNIEXPORT jlong JNICALL Java_JNIFoo_pointers
(JNIEnv *env, jobject obj, jclass cls, jlong addr) {
// if cls is long, then i want to dynamically create the following
// b/c i know the data at *addr* is of type *cls*.
// This works.
jlong* p = (jlong *) addr;
// jclass has the class type and addr has the actual address. But I can't do this
(cls*) p = (cls *) addr;
}
如何创建指向jlong
类型jclass
地址的指针?