D
Doug Trammell
Hello,
I am trying to use JNI to access a C function that processes some data
in a byte[] and returns a new byte[]. I get the following error:
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
at PC=0x807A126
Function=[Unknown.]
Library=C:\J2SDK1~1.2_0\jre\bin\client\jvm.dll
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for
possible
reason and solutions.
Since the function is unknown and it's in the jvm.dll, how can I
figure out what the problem is? I know that generally this type of
error is pointer-related, but how can I track it down? I don't see
anything in the release documentation to help me out here. I have seen
other people with this type of problem, but usually the error occurs
in their native code. This one is in the jvm.dll. Here is my JNI
function:
JNIEXPORT jbyteArray JNICALL Java_testpkg_test(JNIEnv *jnienv, jobject
jobj, jbyteArray data)
{
// Get C variables
int arraySize = jnienv->GetArrayLength(data);
int outputSize;
unsigned char *arrayBytes = (unsigned char *)
jnienv->GetByteArrayElements(data, 0);
// process the array
unsigned char *processedData = processData(arrayBytes, arraySize,
&outputSize);
//create java array with processed data
jbyteArray returnedArray = jnienv->NewByteArray(outputSize);
jnienv->SetByteArrayRegion(returnedArray, 0, outputSize, (signed
char *) processedData);
//release the byte array to the JVM
jnienv->ReleaseByteArrayElements(data, (signed char *)arrayBytes ,
0);
return(returnedArray);
}
Much thanks in advance for any help.
I am trying to use JNI to access a C function that processes some data
in a byte[] and returns a new byte[]. I get the following error:
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
at PC=0x807A126
Function=[Unknown.]
Library=C:\J2SDK1~1.2_0\jre\bin\client\jvm.dll
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for
possible
reason and solutions.
Since the function is unknown and it's in the jvm.dll, how can I
figure out what the problem is? I know that generally this type of
error is pointer-related, but how can I track it down? I don't see
anything in the release documentation to help me out here. I have seen
other people with this type of problem, but usually the error occurs
in their native code. This one is in the jvm.dll. Here is my JNI
function:
JNIEXPORT jbyteArray JNICALL Java_testpkg_test(JNIEnv *jnienv, jobject
jobj, jbyteArray data)
{
// Get C variables
int arraySize = jnienv->GetArrayLength(data);
int outputSize;
unsigned char *arrayBytes = (unsigned char *)
jnienv->GetByteArrayElements(data, 0);
// process the array
unsigned char *processedData = processData(arrayBytes, arraySize,
&outputSize);
//create java array with processed data
jbyteArray returnedArray = jnienv->NewByteArray(outputSize);
jnienv->SetByteArrayRegion(returnedArray, 0, outputSize, (signed
char *) processedData);
//release the byte array to the JVM
jnienv->ReleaseByteArrayElements(data, (signed char *)arrayBytes ,
0);
return(returnedArray);
}
Much thanks in advance for any help.