Here is code, you will need to modify to work
jclass mapClass = (*env)->FindClass(env, "java/util/HashMap");
if(mapClass == NULL)
{
return NULL;
}
jsize map_len = 1;
jmethodID init = (*env)->GetMethodID(env, mapClass, "<init>", "(I)V");
jobject hashMap = (*env)->NewObject(env, mapClass, init, map_len);
jmethodID put = (*env)->GetMethodID(env, mapClass, "put",
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
while( ... )
{
jint key = ...;
size_t sz = t->count;
jbyteArray dd = (*env)->NewByteArray(env, sz);
for(i = 0; i < sz; i++)
{
(*env)->SetByteArrayRegion(env, dd, i, 1, *data++);
}
(*env)->CallObjectMethod(env, hashMap, put, key, dd);
(*env)->DeleteLocalRef(env, key);
(*env)->DeleteLocalRef(env, dd);
}
(*env)->DeleteLocalRef(env, hashMap);
(*env)->DeleteLocalRef(env, mapClass);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…