can i call java method from native code?if so how?

2019-08-20 04:31发布

I have a Java function which can take variable number of parameters and in JNI I am receiving all the parameters in jobjectArray. But the problem is all the parameters available in String type,but originally thy are of different datatype. So in c/c++ converting them to their original type is not possible. So if i could call some other java method which will make these conversions easy for me.is it possible in to call a java method from native code in JNI?

Please help me out. I am really struck at it from a long time. Thanks in advance.

2条回答
混吃等死
2楼-- · 2019-08-20 04:59

Here's a succinct example: http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/method.html.

Fundamentally you need to look up native objects representing the class and method you want to call, format your arguments, call the appropriate JNIEnv->CallXXX method, and process the resulting value.

查看更多
神经病院院长
3楼-- · 2019-08-20 05:06

we can pass the String as a parameter from native code when you callback the java method using env->NewStringUTF(actual parameter).

查看更多
登录 后发表回答