[kaffe] CVS kaffe (guilhem): JNI fixes. Win32 fixes for JNI.

Kaffe CVS cvs-commits at kaffe.org
Tue Jul 6 09:34:31 PDT 2004


PatchSet 4895 
Date: 2004/07/06 16:26:31
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
JNI fixes. Win32 fixes for JNI.

        * configure.ac: Assign JNICALL and JNIEXPORT for Win32 platforms.

        * kaffe/kaffevm/jni/jni-base.c,
        kaffe/kaffe/main.c,
        libraries/clib/native/System.c: Isolate string in userProperties
        from the initializing strings. So they can be freed at any times.

Members: 
	ChangeLog:1.2461->1.2462 
	configure:1.344->1.345 
	configure.ac:1.43->1.44 
	kaffe/kaffe/main.c:1.58->1.59 
	kaffe/kaffevm/jni/jni-base.c:1.3->1.4 
	libraries/clib/native/System.c:1.48->1.49 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2461 kaffe/ChangeLog:1.2462
--- kaffe/ChangeLog:1.2461	Tue Jul  6 15:57:12 2004
+++ kaffe/ChangeLog	Tue Jul  6 16:26:31 2004
@@ -1,3 +1,12 @@
+2004-07-06  Guilhem Lavaux <guilhem at kaffe.org>
+
+	* configure.ac: Assign JNICALL and JNIEXPORT for Win32 platforms.
+
+	* kaffe/kaffevm/jni/jni-base.c,
+	kaffe/kaffe/main.c,
+	libraries/clib/native/System.c: Isolate string in userProperties
+	from the initializing strings. So they can be freed at any times.
+
 2004-07-06  Dalibor Topic  <robilad at kaffe.org>
 
         * kaffe/kaffevm/jit/machine.c,
Index: kaffe/configure
diff -u kaffe/configure:1.344 kaffe/configure:1.345
--- kaffe/configure:1.344	Mon Jul  5 16:39:47 2004
+++ kaffe/configure	Tue Jul  6 16:26:32 2004
@@ -54569,12 +54569,23 @@
 
 
 
+
+case $Khost_os in
+win32*)
+	jnicall_define="__stdcall"
+	jniexport_define="__declspec(dllexport)"
+	;;
+*)
+	jnicall_define=""
+	jniexport_define=""
+	;;
+
 cat >>confdefs.h <<_ACEOF
-#define JNICALL
+#define JNICALL $jnicall_define
 _ACEOF
 
 cat >>confdefs.h <<_ACEOF
-#define JNIEXPORT
+#define JNIEXPORT $jniexport_define
 _ACEOF
 
 
Index: kaffe/configure.ac
diff -u kaffe/configure.ac:1.43 kaffe/configure.ac:1.44
--- kaffe/configure.ac:1.43	Mon Jul  5 16:40:03 2004
+++ kaffe/configure.ac	Tue Jul  6 16:26:40 2004
@@ -1911,8 +1911,19 @@
 dnl Define JNI call.
 dnl -------------------------------------------------------------------------
 
-AC_DEFINE_UNQUOTED(JNICALL, [])
-AC_DEFINE_UNQUOTED(JNIEXPORT, [])
+
+case $Khost_os in
+win32*)
+	jnicall_define="__stdcall"
+	jniexport_define="__declspec(dllexport)"
+	;;
+*)
+	jnicall_define=""
+	jniexport_define=""
+	;;
+
+AC_DEFINE_UNQUOTED(JNICALL, [$jnicall_define])
+AC_DEFINE_UNQUOTED(JNIEXPORT, [$jniexport_define])
 
 dnl -------------------------------------------------------------------------
 
Index: kaffe/kaffe/kaffe/main.c
diff -u kaffe/kaffe/kaffe/main.c:1.58 kaffe/kaffe/kaffe/main.c:1.59
--- kaffe/kaffe/kaffe/main.c:1.58	Mon Jul  5 16:40:18 2004
+++ kaffe/kaffe/kaffe/main.c	Tue Jul  6 16:26:41 2004
@@ -674,19 +674,21 @@
 #endif
 		else if (argv[i][1] ==  'D') {
 			/* Set a property */
+			const char *propStr = strdup(&argv[i][2]);
+			
 			prop = malloc(sizeof(userProperty));
 			assert(prop != 0);
 			prop->next = userProperties;
 			userProperties = prop;
-			for (sz = 2; argv[i][sz] != 0; sz++) {
-				if (argv[i][sz] == '=') {
-					argv[i][sz] = 0;
+			for (sz = 0; propStr[sz] != 0; sz++) {
+				if (propStr[sz] == '=') {
+					propStr[sz] = 0;
 					sz++;
 					break;
 				}
 			}
-			prop->key = &argv[i][2];
-			prop->value = &argv[i][sz];
+			prop->key = propStr;
+			prop->value = &propStr[sz];
 		}
 		else if (argv[i][1] == 'X') {
 			fprintf(stderr, 
Index: kaffe/kaffe/kaffevm/jni/jni-base.c
diff -u kaffe/kaffe/kaffevm/jni/jni-base.c:1.3 kaffe/kaffe/kaffevm/jni/jni-base.c:1.4
--- kaffe/kaffe/kaffevm/jni/jni-base.c:1.3	Tue Jul  6 13:17:23 2004
+++ kaffe/kaffe/kaffevm/jni/jni-base.c	Tue Jul  6 16:26:42 2004
@@ -92,19 +92,21 @@
 	{
 	  userProperty *prop = (userProperty *)malloc(sizeof(userProperty)); 
 	  int sz;
+	  char *internalOpt = strdup(opt);
+
 	  assert (prop != 0);
 
 	  prop->next = userProperties;
 	  userProperties = prop;
 
-	  for (sz = 2; opt[sz] != 0; sz++)
+	  for (sz = 2; internalOpt[sz] != 0; sz++)
 	    {
-	      opt[sz] = 0;
+	      internalOpt[sz] = 0;
 	      sz++;
 	      break;
 	    }
-	  prop->key = &opt[2];
-	  prop->value = &opt[sz];
+	  prop->key = &internalOpt[2];
+	  prop->value = &internalOpt[sz];
 	}
     }
 
Index: kaffe/libraries/clib/native/System.c
diff -u kaffe/libraries/clib/native/System.c:1.48 kaffe/libraries/clib/native/System.c:1.49
--- kaffe/libraries/clib/native/System.c:1.48	Tue May 25 08:33:43 2004
+++ kaffe/libraries/clib/native/System.c	Tue Jul  6 16:26:42 2004
@@ -368,6 +368,17 @@
 		setProperty(p, prop->key, prop->value);
 	}
 
+	prop = userProperties;
+	while (prop != 0) {
+		userProperty *nextProperty = prop->next;
+
+		free(prop->key);
+		free(prop->value);
+		free(prop);
+		prop = nextProperty;
+	}
+	userProperties = NULL;
+
 	return (p);
 }
 




More information about the kaffe mailing list