[kaffe] CVS kaffe (dalibor): Wrapped StringClass in accessor function

Kaffe CVS cvs-commits at kaffe.org
Sun Sep 5 05:28:54 PDT 2004


PatchSet 5143 
Date: 2004/09/05 12:24:46
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Wrapped StringClass in accessor function

2004-09-05  Dalibor Topic  <robilad at kaffe.org>

         * kaffe/kaffevm/baseClasses.c:
        (getStringClass) New function.

        * kaffe/kaffevm/baseClasses.h:
        (getStringClass) Added prototype.

        * kaffe/kaffevm/classMethod.c:
        (refAdded) New local variable to clarify the code.

        * kaffe/kaffevm/gcFuncs.c,
        kaffe/kaffevm/string.c:
        Use getStringClass instead of accessing the StringClass
        directly. This fixes a crash in the verifier with gcjx
        compiled class library.

Members: 
	ChangeLog:1.2699->1.2700 
	kaffe/kaffevm/baseClasses.c:1.54->1.55 
	kaffe/kaffevm/baseClasses.h:1.17->1.18 
	kaffe/kaffevm/classMethod.c:1.122->1.123 
	kaffe/kaffevm/gcFuncs.c:1.56->1.57 
	kaffe/kaffevm/string.c:1.35->1.36 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2699 kaffe/ChangeLog:1.2700
--- kaffe/ChangeLog:1.2699	Sat Sep  4 12:04:53 2004
+++ kaffe/ChangeLog	Sun Sep  5 12:24:46 2004
@@ -1,3 +1,20 @@
+2004-09-05  Dalibor Topic  <robilad at kaffe.org>
+
+	 * kaffe/kaffevm/baseClasses.c:
+	(getStringClass) New function.
+
+	* kaffe/kaffevm/baseClasses.h:
+	(getStringClass) Added prototype.
+
+	* kaffe/kaffevm/classMethod.c:
+	(refAdded) New local variable to clarify the code.
+
+	* kaffe/kaffevm/gcFuncs.c,
+	kaffe/kaffevm/string.c:
+	Use getStringClass instead of accessing the StringClass
+	directly. This fixes a crash in the verifier with gcjx
+	compiled class library.
+
 2004-09-04  Dalibor Topic  <robilad at kaffe.org>
 
 	* kaffe/kaffevm/systems/unix-jthreads/jthread.c:
Index: kaffe/kaffe/kaffevm/baseClasses.c
diff -u kaffe/kaffe/kaffevm/baseClasses.c:1.54 kaffe/kaffe/kaffevm/baseClasses.c:1.55
--- kaffe/kaffe/kaffevm/baseClasses.c:1.54	Sat Jul 17 07:57:13 2004
+++ kaffe/kaffe/kaffevm/baseClasses.c	Sun Sep  5 12:24:48 2004
@@ -101,6 +101,16 @@
 void initClasspath(void);
 void initNative(void);
 
+Hjava_lang_Class* 
+getStringClass(void)
+{
+  if (StringClass == NULL) {
+    loadStaticClass(&StringClass, STRINGCLASS);
+  }
+
+  return StringClass;
+}
+
 /*
  * Initialise the machine.
  *
Index: kaffe/kaffe/kaffevm/baseClasses.h
diff -u kaffe/kaffe/kaffevm/baseClasses.h:1.17 kaffe/kaffe/kaffevm/baseClasses.h:1.18
--- kaffe/kaffe/kaffevm/baseClasses.h:1.17	Tue Jun 15 17:44:47 2004
+++ kaffe/kaffe/kaffevm/baseClasses.h	Sun Sep  5 12:24:48 2004
@@ -61,4 +61,6 @@
 
 extern struct Hjava_lang_ClassLoader *appClassLoader;
 
+extern Hjava_lang_Class* getStringClass(void);
+
 #endif
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.122 kaffe/kaffe/kaffevm/classMethod.c:1.123
--- kaffe/kaffe/kaffevm/classMethod.c:1.122	Thu Aug 19 19:29:02 2004
+++ kaffe/kaffe/kaffevm/classMethod.c	Sun Sep  5 12:24:48 2004
@@ -1542,6 +1542,7 @@
 	Utf8Const *utf8;
 	classEntry* centry;
 	int iLockRoot;
+	bool refAdded;
 
 	utf8 = utf8ConstNew(name, -1);
 	if (!utf8) goto bad;
@@ -1564,7 +1565,8 @@
 			goto bad;
 		}
 		/* we won't ever want to lose these classes */
-		if (!gc_add_ref(clazz)) {
+		refAdded = gc_add_ref(clazz);
+		if (!refAdded) {
 			goto bad;
 		}
 
Index: kaffe/kaffe/kaffevm/gcFuncs.c
diff -u kaffe/kaffe/kaffevm/gcFuncs.c:1.56 kaffe/kaffe/kaffevm/gcFuncs.c:1.57
--- kaffe/kaffe/kaffevm/gcFuncs.c:1.56	Tue Aug  3 18:31:16 2004
+++ kaffe/kaffe/kaffevm/gcFuncs.c	Sun Sep  5 12:24:48 2004
@@ -342,7 +342,7 @@
 /* 1. GCJ work-around, see
  * http://sourceware.cygnus.com/ml/java-discuss/1999-q4/msg00379.html
  */
-				if (FIELD_TYPE(fld) == StringClass) {
+				if (FIELD_TYPE(fld) == getStringClass()) {
 					KGC_markAddress(collector, gc_info, *faddr);
 				} else {
 					KGC_markObject(collector, gc_info, *faddr);
Index: kaffe/kaffe/kaffevm/string.c
diff -u kaffe/kaffe/kaffevm/string.c:1.35 kaffe/kaffe/kaffevm/string.c:1.36
--- kaffe/kaffe/kaffevm/string.c:1.35	Mon Aug  2 10:44:56 2004
+++ kaffe/kaffe/kaffevm/string.c	Sun Sep  5 12:24:48 2004
@@ -479,7 +479,7 @@
 	}
 	
 	memcpy(ARRAY_DATA(ary), data, len * sizeof(jchar));
-	string = (Hjava_lang_String*)newObjectChecked(StringClass, &info);
+	string = (Hjava_lang_String*)newObjectChecked(getStringClass(), &info);
 	if (!string) {
 		discardErrorInfo(&info);
 		return 0;




More information about the kaffe mailing list