I am writing a C application that loads the JVM using JNI. I can open the jvm.dll library and load and call the JNI_CreateJavaVM function successfully.
At that point I do the following:
jstring jstr = NULL;
jobjectArray argArray = NULL;
load the dll and find and call the create function...
jstr = (*env)->NewStringUTF(env, "");
argArray = (*env)->NewObjectArray(env, 5, (*env)->FindClass(env, "java/lang/String"), jstr);
if (argArray == NULL)
{
return -1;
}
The NewStringUTF and NewObjectArray calls seem to corrupt my stack as I can step over the calls and watch other local variables get reassigned. Likewise, the SetObjectArrayElement, FindClass and GetStaticMethodID calls seem to corrupt the same variables.
If I move all my local variables out of the function making them global, everything works up to the exit point of the function which fails because the frame itself has been corrupted. If I keep all my variables global and declare 10 32-bit values (0 - 9) at the beginning of my function, 2, 3 and 5 get corrupted with each call to each of those functions but everything else works fine.
I am running on 32-bit Windows, compiled with Visual Studio 2005, with JRE 1.5.
Any insight would be greatly appreciated.
Thanks,
Brett