Matt Senecal
Posts: 2
Nickname: splatt
Registered: Oct, 2002
|
|
Need JNI help: adding jstrings to jobjectArray
|
Posted: Oct 15, 2002 8:17 AM
|
|
Advertisement
|
I'm trying to add jstrings to a jobjectArray, but I keep getting ArrayStoreExceptions, and I can't figure out why.
The array is declared here:
jclass strArrCls = (*env)->FindClass(env, "[Ljava/lang/String;"); apiData = (*env)->NewObjectArray(env, 24, strArrCls, NULL);
The string I'm adding is a field from a C struct. The C struct is defined as:
#ifndef __APIPARAMS_H #define __APIPARAMS_H
typedef struct { char *year; } ApiParams; #endif
I'm doing the conversion and add here:
jstring tempString; tempString = (*env)->NewStringUTF(env, theParams->year); (*env)->SetObjectArrayElement(env, apiData, 0, tempString);
And that's where the exception is thrown. As far as I can tell, this should work. Am I missing something?
|
|