3

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?

4

2 に答える 2

1

JNICALLおそらく#define JNICALL __stdcallです。__stdcall呼び出し規約を変更すると名前の装飾が修正されますが、何か他のものを想定して取得する関数を呼び出すため、JNIはひどく(黙って含む)壊れます。

それは実際には機能しませんか?私がグーグルできることから、JVMは関数名を適切に装飾する方法を知っているようです。

于 2010-03-17T17:04:21.533 に答える
0

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.

于 2010-03-17T16:56:13.000 に答える