When using %native to use one's own JNI function
definition, SWIG generates just the function declaration
as expected, but then it also generates the JNI function
definition as well (the function declaration we did not
want to be generated).
See included file, module_wrap.cxx :
Line 85 - The function definition only, as expected .
Line 104 - 126 - The function definition which should not
be there
Project Zip Archive
Sorry nobody responded to this before. Better late than never hopefully!
Looking at the examples of use of
%nativeand the manual section about it,%nativeis there to handle wrapping a hand-coded JNI function rather than to replace the JNI wrapping generated for a C/C++ function with hand-coded JNI:If you want to also have SWIG ignore the
negatefunction prototype and effectively replace the JNI it would generate then you need to use%ignoreto ignore the C prototype as well as%nativeto specify the hand coded JNI.If I add this to your example, I get the result you want:
I've also added a note to the docs to clarify this point: