[kaffe] CVS kaffe (guilhem): Added basic support for java.endorsed.dirs

Kaffe CVS cvs-commits at kaffe.org
Tue Apr 18 03:16:18 PDT 2006


PatchSet 7232 
Date: 2006/04/18 10:06:37
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Added basic support for java.endorsed.dirs

        * kaffe/kaffevm/findInJar.c,
        kaffe/kaffevm/support.h
        (KaffeVM_addClasspath, KaffeVM_prependClasspath): Renamed to
        prevent namespace collision.

        * kaffe/kaffevm/jni/jni-base.c
        (KaffeJNI_getSystemProperty, KaffeJNI_addEndorsedDirs): New
        functions.

Members: 
	ChangeLog:1.4738->1.4739 
	kaffe/kaffevm/findInJar.c:1.72->1.73 
	kaffe/kaffevm/support.h:1.45->1.46 
	kaffe/kaffevm/jni/jni-base.c:1.26->1.27 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4738 kaffe/ChangeLog:1.4739
--- kaffe/ChangeLog:1.4738	Mon Apr 17 20:00:37 2006
+++ kaffe/ChangeLog	Tue Apr 18 10:06:37 2006
@@ -1,3 +1,14 @@
+2006-04-18  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* kaffe/kaffevm/findInJar.c,
+	kaffe/kaffevm/support.h
+	(KaffeVM_addClasspath, KaffeVM_prependClasspath): Renamed to
+	prevent namespace collision.
+
+	* kaffe/kaffevm/jni/jni-base.c
+	(KaffeJNI_getSystemProperty, KaffeJNI_addEndorsedDirs): New
+	functions.
+
 2006-04-17  Dalibor Topic  <robilad at kaffe.org>
 
 	* TODO: Updated, as fastjar has been merged in.
Index: kaffe/kaffe/kaffevm/findInJar.c
diff -u kaffe/kaffe/kaffevm/findInJar.c:1.72 kaffe/kaffe/kaffevm/findInJar.c:1.73
--- kaffe/kaffe/kaffevm/findInJar.c:1.72	Sun Feb 12 19:14:35 2006
+++ kaffe/kaffe/kaffevm/findInJar.c	Tue Apr 18 10:06:38 2006
@@ -455,11 +455,11 @@
 		end = strstr(cp, path_separator);
 		if (end != 0) {
 			*end = '\0';
-			addClasspath(cp);
+			KaffeVM_addClasspath(cp);
 			cp = end + strlen(path_separator);
 		}
 		else {
-			addClasspath(cp);
+			KaffeVM_addClasspath(cp);
 			break;
 		}
 	}
@@ -487,10 +487,10 @@
 	}
 
 	/* Add '.' and <home>/lib/rt.jar at the beginning */
-	addClasspath(".");
+	KaffeVM_addClasspath(".");
 	buf = KMALLOC(strlen(home) + strlen(KLASSES_JAR) + 6);
 	sprintf(buf, "%s/lib/%s", home, KLASSES_JAR);
-	addClasspath(buf);
+	KaffeVM_addClasspath(buf);
 	KFREE(buf);
 
 	hlen = strlen(home);
@@ -501,7 +501,7 @@
 		    || strcmp(&name[len-4], ".jar") == 0)) {
 			buf = KMALLOC(strlen(home) + strlen(name) + 2);
 			sprintf(buf, "%s/%s", home, name);
-			addClasspath(buf);
+			KaffeVM_addClasspath(buf);
 			KFREE(buf);
 		}
 	}
@@ -513,7 +513,7 @@
  * Append an entry in the Classpath dynamically.
  */
 int
-addClasspath(const char* cp)
+KaffeVM_addClasspath(const char* cp)
 {
 	return insertClasspath(cp, 0);
 }
@@ -522,7 +522,7 @@
  * Prepend an entry in the Classpath dynamically.
  */
 int
-prependClasspath(const char* cp)
+KaffeVM_prependClasspath(const char* cp)
 {
 	return insertClasspath(cp, 1);
 }
Index: kaffe/kaffe/kaffevm/support.h
diff -u kaffe/kaffe/kaffevm/support.h:1.45 kaffe/kaffe/kaffevm/support.h:1.46
--- kaffe/kaffe/kaffevm/support.h:1.45	Sun Mar 19 16:16:21 2006
+++ kaffe/kaffe/kaffevm/support.h	Tue Apr 18 10:06:38 2006
@@ -144,8 +144,8 @@
 extern void SignalErrorf(const char *, const char *, ...) PRINTFFORMAT(2,3);
 extern void unimp(const char*);
 extern void kprintf(FILE*, const char*, ...) PRINTFFORMAT(2,3);
-extern int addClasspath(const char*);
-extern int prependClasspath(const char*);
+extern int KaffeVM_addClasspath(const char*);
+extern int KaffeVM_prependClasspath(const char*);
 
 void classname2pathname(const char* from, char* to);
 void pathname2classname(const char* from, char* to);
Index: kaffe/kaffe/kaffevm/jni/jni-base.c
diff -u kaffe/kaffe/kaffevm/jni/jni-base.c:1.26 kaffe/kaffe/kaffevm/jni/jni-base.c:1.27
--- kaffe/kaffe/kaffevm/jni/jni-base.c:1.26	Sun Apr 16 23:49:17 2006
+++ kaffe/kaffe/kaffevm/jni/jni-base.c	Tue Apr 18 10:06:38 2006
@@ -27,6 +27,7 @@
 #include "classMethod.h"
 #include "jvmpi_kaffe.h"
 #include "external.h"
+#include "system.h"
 
 /*
  * Keep track of how many VM's are active. Right now
@@ -267,6 +268,19 @@
   return 1;
 }
 
+static char *
+KaffeJNI_getSystemProperty(const char *key)
+{
+  jvalue retval;
+  Hjava_lang_String *key_string = stringC2Java(key);
+  
+  do_execute_java_class_method(&retval, "gnu/classpath/SystemProperties", NULL, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;", key_string);
+  if (retval.l == NULL)
+    return NULL;
+
+  return stringJava2C(retval.l);
+}
+
 #if defined(ENABLE_JVMPI)
 
 static void
@@ -284,6 +298,25 @@
 
 #endif /* defined(ENABLE_JVMPI) */
 
+static void KaffeJNI_addEndorsedDirs()
+{
+  char *endorsed = KaffeJNI_getSystemProperty("java.endorsed.dirs");
+  char *sep;
+  char *save_endorsed = endorsed;
+
+  if (endorsed == NULL)
+    return;
+
+  while ((sep = strstr(endorsed, path_separator)) != NULL)
+    {
+      *sep = 0;
+      KaffeVM_prependClasspath(endorsed);
+      endorsed = sep+1;
+    }
+
+  gc_free(save_endorsed);
+}
+
 jint
 JNI_CreateJavaVM(JavaVM** vm, void** penv, void* args)
 {
@@ -312,6 +345,8 @@
 
   /* Setup the machine */
   initialiseKaffe();
+
+  KaffeJNI_addEndorsedDirs();
 
   /* Return the VM and JNI we're using */
   *vm = KaffeJNI_GetKaffeVM();




More information about the kaffe mailing list