[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
libclasspath const/non-const warnings (was: Re: fix const/non-const warn
From: |
Steven Augart |
Subject: |
libclasspath const/non-const warnings (was: Re: fix const/non-const warnings in jcl.c, jcl.h) |
Date: |
Mon, 21 Jun 2004 15:29:57 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 |
Michael Koch wrote:
Can you provide two patches, one for functional changes and one for
the reformatting ? This makes it easier later to track changes.
This is the patch for functional changes, using the reformatted code
as a base.
--
Steven Augart
Jikes RVM, a free, open source, Virtual Machine:
http://oss.software.ibm.com/jikesrvm
These are the substantive changes.
2004-06-21 Steven Augart <address@hidden>
* native/jni/classpath/jcl.c, native/jni/classpath/jcl.h
(JCL_FindClass): Fixed const/non-const warning in function prototype.
(JCL_ThrowException): Idem.
(JCL_free_cstring): Fixed logical const/non-const problem in
function prototype.
* native/jni/classpath/jnilink.c, native/jni/classpath/jnilink.h
(LINK_ReallyLinkClass): Fix const/non-const warning in function
prototype.
(LINK_RelinkClass): Idem.
(LINK_RelinkMethod): Idem.
(LINK_RelinkStaticMethod): Idem.
(LINK_RelinkField): Idem.
(LINK_RelinkStaticField): Idem.
* native/jni/classpath/primlib.c (nativeWrapClassName): Make const.
(nativeWrapClassConstructorSig): Idem.
(nativeWrapClassAccessorName): Idem.
(nativeWrapClassAccessorSig): Idem.
--- native/jni/classpath/jcl.c.reformatted 2004-06-21 18:51:47.000000000
+0000
+++ native/jni/classpath/jcl.c 2004-06-21 19:06:28.000000000 +0000
@@ -47,7 +47,7 @@
#endif
JNIEXPORT void JNICALL
-JCL_ThrowException (JNIEnv * env, char *className, char *errMsg)
+JCL_ThrowException (JNIEnv * env, const char *className, const char *errMsg)
{
jclass excClass;
if ((*env)->ExceptionOccurred (env))
@@ -72,9 +72,9 @@
return;
}
}
- /* Removed this (more comprehensive) error string to avoid the need for
a
- * static variable or allocation of a buffer for this message in this
(unlikely)
- * error case. --Fridi.
+ /* Removed this (more comprehensive) error string to avoid the need for
+ * a static variable or allocation of a buffer for this message in this
+ * (unlikely) error case. --Fridi.
*
* sprintf(errstr,"JCL: Failed to throw exception %s with message %s:
could not find exception class.", className, errMsg);
*/
@@ -139,7 +139,7 @@
}
JNIEXPORT void JNICALL
-JCL_free_cstring (JNIEnv * env, jstring s, const char *cstr)
+JCL_free_cstring (JNIEnv * env, jstring s, char *cstr)
{
(*env)->ReleaseStringUTFChars (env, s, cstr);
}
@@ -169,7 +169,7 @@
}
JNIEXPORT jclass JNICALL
-JCL_FindClass (JNIEnv * env, char *className)
+JCL_FindClass (JNIEnv * env, const char *className)
{
jclass retval = (*env)->FindClass (env, className);
if (retval == NULL)
--- native/jni/classpath/jcl.h.reformatted 2004-06-21 18:51:47.000000000
+0000
+++ native/jni/classpath/jcl.h 2004-06-21 19:08:43.000000000 +0000
@@ -42,16 +42,16 @@
#include <jni.h>
#include <config.h>
-JNIEXPORT jclass JNICALL JCL_FindClass (JNIEnv * env, char *className);
-JNIEXPORT void JNICALL JCL_ThrowException (JNIEnv * env, char *className,
- char *errMsg);
+JNIEXPORT jclass JNICALL JCL_FindClass (JNIEnv * env, const char *className);
+JNIEXPORT void JNICALL JCL_ThrowException (JNIEnv * env,
+ const char *className,
+ const char *errMsg);
JNIEXPORT void *JNICALL JCL_malloc (JNIEnv * env, size_t size);
JNIEXPORT void *JNICALL JCL_realloc (JNIEnv * env, void *ptr, size_t size);
JNIEXPORT void JNICALL JCL_free (JNIEnv * env, void *p);
JNIEXPORT const char *JNICALL JCL_jstring_to_cstring (JNIEnv * env,
jstring s);
-JNIEXPORT void JNICALL JCL_free_cstring (JNIEnv * env, jstring s,
- const char *cstr);
+JNIEXPORT void JNICALL JCL_free_cstring (JNIEnv * env, jstring s, char *cstr);
JNIEXPORT jint JNICALL JCL_MonitorEnter (JNIEnv * env, jobject o);
JNIEXPORT jint JNICALL JCL_MonitorExit (JNIEnv * env, jobject o);
--- native/jni/classpath/jnilink.c.reformatted 2004-06-21 18:51:47.000000000
+0000
+++ native/jni/classpath/jnilink.c 2004-06-21 19:14:01.000000000 +0000
@@ -45,7 +45,7 @@
#define GETCLASS(c) *(jclass*)(c)
JNIEXPORT jclass JNICALL
-LINK_RelinkClass (JNIEnv * env, linkedClass * c, char *name)
+LINK_RelinkClass (JNIEnv * env, linkedClass * c, const char *name)
{
jclass found;
LINK_UnlinkClass (env, *c);
@@ -77,7 +77,7 @@
JNIEXPORT jmethodID JNICALL
LINK_RelinkMethod (JNIEnv * env, jmethodID * m, linkedClass c,
- char *name, char *sig)
+ const char *name, const char *sig)
{
*m = (*env)->GetMethodID (env, GETCLASS (c), name, sig);
return *m;
@@ -85,7 +85,7 @@
JNIEXPORT jmethodID JNICALL
LINK_RelinkStaticMethod (JNIEnv * env, jmethodID * m, linkedClass c,
- char *name, char *sig)
+ const char *name, const char *sig)
{
*m = (*env)->GetStaticMethodID (env, GETCLASS (c), name, sig);
return *m;
@@ -93,7 +93,7 @@
JNIEXPORT jfieldID JNICALL
LINK_RelinkField (JNIEnv * env, jfieldID * f, linkedClass c,
- char *name, char *sig)
+ const char *name, const char *sig)
{
*f = (*env)->GetFieldID (env, GETCLASS (c), name, sig);
return *f;
@@ -101,7 +101,7 @@
JNIEXPORT jfieldID JNICALL
LINK_RelinkStaticField (JNIEnv * env, jfieldID * f, linkedClass c,
- char *name, char *sig)
+ const char *name, const char *sig)
{
*f = (*env)->GetStaticFieldID (env, GETCLASS (c), name, sig);
return *f;
--- native/jni/classpath/jnilink.h.reformatted 2004-06-21 18:51:47.000000000
+0000
+++ native/jni/classpath/jnilink.h 2004-06-21 19:13:05.000000000 +0000
@@ -53,25 +53,25 @@
#define LINK_LinkConstructor(env,m,c,sig) ((m)==NULL ?
LINK_RelinkMethod((env),&(m),(c),"<init>",(sig)) : (m))
JNIEXPORT jclass JNICALL
-LINK_ReallyLinkClass (JNIEnv * env, linkedClass * c, char *name);
+LINK_ReallyLinkClass (JNIEnv * env, linkedClass * c, const char *name);
JNIEXPORT jclass JNICALL
LINK_ReallyLinkKnownClass (JNIEnv * env, linkedClass * c, jclass newClass);
JNIEXPORT jclass JNICALL
-LINK_RelinkClass (JNIEnv * env, linkedClass * c, char *name);
+LINK_RelinkClass (JNIEnv * env, linkedClass * c, const char *name);
JNIEXPORT jclass JNICALL
LINK_RelinkKnownClass (JNIEnv * env, linkedClass * c, jclass newClass);
JNIEXPORT jmethodID JNICALL
LINK_RelinkMethod (JNIEnv * env, jmethodID * m, linkedClass c,
- char *name, char *sig);
+ const char *name, const char *sig);
JNIEXPORT jmethodID JNICALL
LINK_RelinkStaticMethod (JNIEnv * env, jmethodID * m, linkedClass c,
- char *name, char *sig);
+ const char *name, const char *sig);
JNIEXPORT jfieldID JNICALL
LINK_RelinkField (JNIEnv * env, jfieldID * f, linkedClass c,
- char *name, char *sig);
+ const char *name, const char *sig);
JNIEXPORT jfieldID JNICALL
LINK_RelinkStaticField (JNIEnv * env, jfieldID * f, linkedClass c,
- char *name, char *sig);
+ const char *name, const char *sig);
/* These are for when the class referencing the symbols is unloaded; it
destroys any object references
--- native/jni/classpath/primlib.c.reformatted 2004-06-21 18:51:47.000000000
+0000
+++ native/jni/classpath/primlib.c 2004-06-21 19:09:53.000000000 +0000
@@ -59,7 +59,7 @@
NULL, NULL, NULL, NULL, NULL, NULL
};
-static char *nativeWrapClassName[PRIMLIB_NUMTYPES] = {
+static const char *nativeWrapClassName[PRIMLIB_NUMTYPES] = {
NULL,
NULL,
"java/lang/Boolean",
@@ -74,7 +74,7 @@
NULL
};
-static char *nativeWrapClassConstructorSig[PRIMLIB_NUMTYPES] = {
+static const char *nativeWrapClassConstructorSig[PRIMLIB_NUMTYPES] = {
NULL,
NULL,
"(Z)V",
@@ -89,7 +89,7 @@
NULL
};
-static char *nativeWrapClassAccessorName[PRIMLIB_NUMTYPES] = {
+static const char *nativeWrapClassAccessorName[PRIMLIB_NUMTYPES] = {
NULL,
NULL,
"booleanValue",
@@ -104,7 +104,7 @@
NULL
};
-static char *nativeWrapClassAccessorSig[PRIMLIB_NUMTYPES] = {
+static const char *nativeWrapClassAccessorSig[PRIMLIB_NUMTYPES] = {
NULL,
NULL,
"()Z",