Posted By:
Matt_Senecal
Posted On:
Monday, October 14, 2002 01:30 PM
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 as such: jclass strArrCls = (*env)->FindClass(env, "[Ljava/lang/String;"); apiData = (*env)->NewObjectArray(env, 24, strArrCls, NULL); Neither "strArrCls" nor "apiData" come back as NULL. No exceptions are thrown when creating the array. The string I'm adding to the array 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
More>>
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 as such:
jclass strArrCls = (*env)->FindClass(env, "[Ljava/lang/String;");
apiData = (*env)->NewObjectArray(env, 24, strArrCls, NULL);
Neither "strArrCls" nor "apiData" come back as NULL. No exceptions are thrown when creating the array.
The string I'm adding to the array 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, inside another method:
int doConvert(ApiParams* theParams, jobjectArray apiData)
{
jstring tempString;
tempString = (*env)->NewStringUTF(env, theParams->year);
(*env)->SetObjectArrayElement(env, apiData, 0, tempString);
}
And that's where the exception is thrown. TempString is not NULL. As far as
I can tell, this should work, but it's not. Am I missing something?
<<Less