JNI ByteBuffer使用

11-04 2481人

jlong JNICALL Java_com_example_numbercalculate_NumberJNI_process1(JNIEnv *env,
  jobject obj, jobject buffer) {
 jclass cls = env->GetObjectClass(buffer);
 jmethodID mid = env->GetMethodID(cls, "limit", "(I)Ljava/nio/Buffer;");
 char *buf = (char*) env->GetDirectBufferAddress(buffer);
 jlong capacity = env->GetDirectBufferCapacity(buffer);
 int var;
 const char *test = NULL;
 test = "hello";
 // Do something spectacular with the buffer...
 memcpy(buf, test, strlen(test));
 env->CallObjectMethod(buffer, mid, var);
 return capacity;
}


	
色迷迷 哭 呕吐 大笑 口水 微笑 啵一个 发怒

Hi,您需要填写昵称和邮箱!

  • 必填项
  • 必填项