如何从C调用Java方法++

如何从C调用Java方法++

问题描述:

我使用JNI调用我的C ++与Java的功能。其中一个C ++函数的参数是 jobject THIZ (据我所知,所有的JNI本机的功能有这种说法)。该功能需要相当长时间才能完成,我想报告进度回 jobject THIZ Java对象,这样我就可以显示进度给用户。我怎么能叫jobject的方法从C ++?

I am using JNI to call my C++ function from Java. One of the C++ function's arguments is jobject thiz (as far as I know, all JNI native functions have this argument). The function takes quite long to complete and I want to report progress back to the jobject thiz Java object, so that I can show the progress to the user. How can I call jobject's methods from C++?

您需要看看JNI函数的GetMethodID 呼叫<类型>方法*

You need to look at the JNI functions GetMethodID and Call<type>Method*.

的各种变种的细节以及如何调用它们都记录了的 JNI规范

The details of the various variants and how to call them are documented the JNI specification.