
Signature
Daniel Dyer
http://www.dandyer.co.uk
> JNI uses C calling conventions. The C++ compiler will mangle your
> function names if you don't wrap your C++ code in the following:
[quoted text clipped - 8 lines]
> }
> #endif
While your comment is perfectly correct, I'd just like to add that if
you use the exact names and signatures generated by javah and also
include the generated header file, then the functions will already be
declared extern "C".
The OP also needs to watch out for another kind of mangling typical
for MS windows, described here:
http://en.wikipedia.org/wiki/Name_mangling
Use an inspection tool to see what the library really contains after
compiling.
Finally, it's important to realize that if a package declaration was
used in the Java source, then the header and the native source files
should reflect that (the fully qualified classname should have been
specified when generating the header file).
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
M. Fernandez - 03 Apr 2006 22:26 GMT
Thanks a lot for your help,
I have found my error with your useful remarks. Actually I has been
accessing the java objects in a bad was. I was calling the JNI functions
with a "static method" and this is obviously wrong (because I have
declared them as object methods).
I just have another question, Do you know an inspector tool for the dll
libraries (Windows, Linux or multi-platform ) ??
thanks,
MArcelo
Gordon Beaton - 04 Apr 2006 08:30 GMT
> I just have another question, Do you know an inspector tool for the
> dll libraries (Windows, Linux or multi-platform ) ??
On Linux and all Unix dialects: objdump and nm.
I don't use Windows, but others have mentioned things like dumpbin,
quickview and depends, which I know nothing about.
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Chris Uppal - 04 Apr 2006 09:35 GMT
> I don't use Windows, but others have mentioned things like dumpbin,
> quickview and depends, which I know nothing about.
On Windows, Dependency Walker (aka depends) is my preferred tool.
http://www.dependencywalker.com/
Free.
-- chris
Chris Uppal - 04 Apr 2006 10:24 GMT
> The OP also needs to watch out for another kind of mangling typical
> for MS windows, described here:
>
> http://en.wikipedia.org/wiki/Name_mangling
The JVM is aware of that kind of decoration and checks (on Windows) for both
decorated and undecorated forms of the name:
_some_function@8
and
some_function
It does something similar on other OSs.
> Use an inspection tool to see what the library really contains after
> compiling.
Agreed, most especially if one is using an "unusual" compiler
-- chris