Let's say I have some structure
struct DetectItem { int x; int y; DetectItem(): x(0), y(0) {} } And getting her pointer:
JNIEXPORT jlong JNICALL Java_com_create(JNIEnv *env, jobject obj) { DetectItem detectItem = CreateNewDetectItem(); return (jlong) &detectItem; } Then I try to get this created DetectItem through the following function:
JNIEXPORT jint JNICALL Java_com_get(JNIEnv *env, jobject obj, jlong handle) { DetectItem* di = (DetectItem*) handle; return (jint)di->x; } But as a result, I get the result -858993460 , although if you add cout to Java_com_create , then the DetectItem object contains normal values. How to make it work? I understand that in create I give a pointer to an object, and in get I accept it, but it does not work :(
std::map<jlong, DetectItem> mappedlike this. - lampa