Here is an excerpt of C++ code that is called from a Java JVM via JNI:
(JNIEnv *pJniEnv, jobject, jstring pDllName)
{
string dllName(pJniEnv->GetStringUTFChars(pDllName, NULL));
// stuff happens here like
HINSTANCE loadedDll = LoadLibrary(dllName.c_str());
pJniEnv->ReleaseStringUTFChars(pDllName, dllName.c_str());
return ...;
}
This works in Windows XP but crashes in Windows 7 with an access violation exception, in the line
pJniEnv->ReleaseStringUTFChars(pDllName, dllName.c_str());
The error message is:
First-chance exception at 0x77355F29 (ntdll.dll) in java.exe: 0xC0000005: Access violation reading location 0x002B0D52.
I'd be thankful for any clues.
JRE version: 6.0_27-b07, Java VM: Java HotSpot(TM) Client VM (20.2-b06 mixed mode windows-x86 ), C++ Code was built with Visual Studio 2010.