[java-gnome-hackers] jcharArray, jbyteArray, jstring
Brought to you by:
afcowie
From: Mark H. <mh...@ti...> - 2002-12-26 15:00:12
|
Hi, I've been trying some of the other applications again and coming into yet more problems which I assume to be related to passing byte arrays. I'm not entirely sure why I'm encountering them and noone else is - I am just using normal english and even the same source files in some cases. I guess it must be a difference between kaffe and java. The latest methods I've found problems with are for new Gtk Labels and Frames. This is all autogenerated code: JNIEXPORT jint JNICALL Java_org_gnu_gtk_Label_gtk_1label_1new (JNIEnv *env, jclass cls, jbyteArray str) { jint str_len = (*env)->GetArrayLength(env, str); gchar* str_g = (gchar*)g_malloc(str_len + 1); (*env)->GetByteArrayRegion(env, str, 0, str_len, (jbyte*)str_g); str_g[str_len] = 0; { return (jint)gtk_label_new (str_g); } } I've found that changing it to this fixes the problems (for me at least) JNIEXPORT jint JNICALL Java_org_gnu_gtk_Label_gtk_1label_1new (JNIEnv *env, jclass cls, jstring str) { const gchar *str_g = (*env)->GetStringUTFChars(env, str, 0); { return (jint)gtk_label_new (str_g); } } Is this the best way to handle it? -- .''`. Mark Howard : :' : `. `' http://www.tildemh.com `- mh...@de... | mh...@ti... | mh...@ca... |