我想通过jni将java树形图传递给c。我称之为本地方法:JNI将树形图从java传递到c
public native int getEuklid(TreeMap<int,short[]> map);
static {
System.loadLibrary("Euklid");
}
现在在我的c文件中,我想访问地图中的元素。我怎么能做到这一点。这是我c文件中的头文件:
JNIEXPORT int JNICALL
Java_Main_getEuklid (JNIEnv *env, jobject o, jobject o2)
其中o2是树形图。我该如何处理像java中的treemap那样的jobject?
编辑:
哪里是我的错?:
JNIEXPORT int JNICALL
Java_Main_getEuklid (JNIEnv *env, jobject o, jobject o2){
jclass cls = env->GetObjectClass(o2) ;
jmethodID mGetValue = env->GetMethodID(cls, "keySet","()Ljava/util/Set;");
jobject value = env->CallObjectMethod(o2, mGetValue)
我变成了:
In function ‘Java_Main_getEuklid’:
11: error: request for member ‘GetObjectClass’ in something not a structure or union
12: error: request for member ‘GetMethodID’ in something not a structure or union
13: error: request for member ‘CallObjectMethod’ in something not a structure or union
我在C真正的新和我想要测试的东西,所以我希望你能帮我。
相关:http://stackoverflow.com/questions/4844022/jni-create-hashmap和http://stackoverflow.com/questions/5641499/making-generic-calls-with-java-jni-and-c – Cratylus 2013-04-21 17:38:36
我已经编辑我的文章 – bladepit 2013-04-21 17:52:02