Overload JNI Method

被刻印的时光 ゝ 提交于 2019-12-11 09:37:41

问题


I have an existing JNI method with two parameters. Been around for a while, in use, so I don't want to just change it lest the wrath of angry customers be unleashed.

But, I now need to make an adjustment.

So, I thought, make a second overloaded method with the extra parameter and deprecate the two-parameter version. That part went fine, jar builds and runs with no issues.

The problem is in the C++ side... I defined two methods, one being a wrapper for the other (two parameter calls the three parameter version), but, when I went to export the two methods, I receive:

Error   1   error C2733: second C linkage of overloaded function 'Java_com_xxx' not allowed

So, what do I do to keep the old method name and add a new method with new parameters? Is this doable?


回答1:


Run javah on your Java file declaring the native methods and you will see that you need two different Java_com_xxx functions. The C-level declarations must be unique.



来源:https://stackoverflow.com/questions/28637023/overload-jni-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!