JNI how to access Java Object (Integer)

前端 未结 2 1819
不知归路
不知归路 2020-12-24 15:49

I have a JNI method to access java method which returns an Integer object. I do not want to return the primitive int type because this code will be modified to handle Generi

2条回答
  •  执念已碎
    2020-12-24 15:57

    You have to invoke the intValue method on the Integer instance to get its primitive value. Use FindClass instead of GetObjectClass (as in your code) to get a reference to the class java.lang.Integer and then GetMethodID and CallObjectMethod to actually invoke the intValue method.

提交回复
热议问题