Question

I manage project for JNI for both compilers: MSVC++ 8.0 and 9.0, my cpp file contains following implementation: extern "C" { JNIEXPORT jlong JNICALL Java_context_ServiceProviderContext_StartServiceProvider (JNIEnv * env, jclass, jstring jspath){ ..... }

With help of depends.exe utility I can see that MSVC 8.0 successfully exports function as it is expected: Java_context_ServiceProviderContext_StartServiceProvider But compiling under MSVC 9.0 gets me crazy it exports like ignoring extern "C" at all. depends.exe shows me: _Java_context_ServiceProviderContext_StartServiceProvider@12

Does anybody know what exactly in 9.0 project that causes this behavior?

Was it helpful?

Solution

JNICALL is probably #define JNICALL __stdcall. Changing the calling convention will fix the name decoration, but it will horribly (including silently) break JNI, as it will be calling a function assuming __stdcall and getting something else.

Does it actually not work? From what I can google it seems that the JVM knows how to decorate the function names properly.

OTHER TIPS

That's __stdcall calling convention; you need __cdecl. Maybe try adding __cdecl to your function's definition?

Alternatively, change the default calling convention in the project settings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top