A
abhijeet.s
Fews days back; I completed developement of a JNI module where in I
added support for few C++ native methods to be called from Java. For
those methods native method call succeeds from Java sample program ; it
works till date; But for new methods that I added into module today it
gives me java.lang.UnsatisfiedLinkError.
I used dependency viewer & I tried to find out mangled names; all
functions have something '@X' some number in the end even old methods
too!. After reading so many articles I came to know that it should be
problem with C++ compiler doing some dirty work (name mangling).
somehwhere I got the answer also; advised me to use extern "C" to
prevent that. But to my surprise, .h generated by javah -jni, contains
black extern "C". It means that compiler should not mangle the names;
but doing it!
I haven't understand 2 things. If this had been a problem of name
mangling by C++ compiler, I would have not able to call any of the
method; but call succeeds for old ones. How come?
Any other way how to prevent "MS" stupid compiler from doing this.
Any help on this will really be appriciated.
Regards
Abhijeet
added support for few C++ native methods to be called from Java. For
those methods native method call succeeds from Java sample program ; it
works till date; But for new methods that I added into module today it
gives me java.lang.UnsatisfiedLinkError.
I used dependency viewer & I tried to find out mangled names; all
functions have something '@X' some number in the end even old methods
too!. After reading so many articles I came to know that it should be
problem with C++ compiler doing some dirty work (name mangling).
somehwhere I got the answer also; advised me to use extern "C" to
prevent that. But to my surprise, .h generated by javah -jni, contains
black extern "C". It means that compiler should not mangle the names;
but doing it!
I haven't understand 2 things. If this had been a problem of name
mangling by C++ compiler, I would have not able to call any of the
method; but call succeeds for old ones. How come?
Any other way how to prevent "MS" stupid compiler from doing this.
Any help on this will really be appriciated.
Regards
Abhijeet