I have the following C ++ code for the JNI shell:
#include "map_container.h" extern "C" { JNIEXPORT void JNICALL Java_com_map_Map_openMapNative(JNIEnv* env, jobject thiz, jstring path); }; static map_container* map = NULL; void Java_com_map_Map_openMapNative(JNIEnv* env, jobject thiz, jstring path) { const char* filename_utf8 = env->GetStringUTFChars(path, false); if ( mapview ) { delete mapview; mapview = NULL; } mapview = new map_container((char*)filename_utf8); if (filename_utf8) { env->ReleaseStringUTFChars(path, filename_utf8); } }
and com.map.Map.openMapNative declared as static, which means that I can manage one map at a time. How can I change this code in C ++ so that map_container* map becomes non-static and belongs to the exact instance of the com.map.Map class? map_container is a fully C ++ class and is not reflected in Java.
source share