Hi list,

I was worried about some compiler warnings when compiling the native 
part of the gtk peer. So I digged a little bit. In jni.h in GNU 
classpath GetStringUTFChars returns "const jbyte *". This gives 
compiler warnings when assigning the return value to a "const char *" 
variable. I found out that in jni.h from GCJ (3.3 and 3.5) and jni.h 
from Mozilla GetStringUTFChars returns "const char *" which is much 
more logical and seems to be the right thing. JNI 1.1 spec says it 
should return "const jbyte *". I search a little bit with google and 
jni.h in other open source projects use "const char *" too. Now I 
really wonder what we should do ? Should we leave it like it is and 
cast to "const char *" in all instances we use GetStringUTFChars in out 
own code or should we just apply the attached patch to change our 
jni.h.

What do you think ?


Michael


2004-04-28  Michael Koch  <[EMAIL PROTECTED]>

        * include/jni.h.in (GetStringUTFChars):
        Made it return const char * instead of const jbyte *.

Index: include/jni.h.in
===================================================================
RCS file: /cvsroot/classpath/classpath/include/jni.h.in,v
retrieving revision 1.7
diff -u -r1.7 jni.h.in
--- include/jni.h.in	29 Mar 2004 07:07:26 -0000	1.7
+++ include/jni.h.in	28 Apr 2004 07:44:16 -0000
@@ -392,7 +392,7 @@
   void     (JNICALL *ReleaseStringChars)           (JNIEnv *, jstring, const jchar *);              /* 166 */
   jstring  (JNICALL *NewStringUTF)                 (JNIEnv *, const char *);                        /* 167 */
   jsize    (JNICALL *GetStringUTFLength)           (JNIEnv *, jstring);                             /* 168 */
-  const jbyte * (JNICALL *GetStringUTFChars)       (JNIEnv *, jstring, jboolean *);                 /* 169 */
+  const char * (JNICALL *GetStringUTFChars)       (JNIEnv *, jstring, jboolean *);                 /* 169 */
   void     (JNICALL *ReleaseStringUTFChars)        (JNIEnv *, jstring, const char *);               /* 170 */
   jsize    (JNICALL *GetArrayLength)               (JNIEnv *, jarray);                              /* 171 */
   jarray   (JNICALL *NewObjectArray)               (JNIEnv *, jsize, jclass, jobject);              /* 172 */
_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to