[kaffe] CVS kaffe (guilhem): Fix for bug #14

Kaffe CVS cvs-commits at kaffe.org
Sun Mar 19 08:27:46 PST 2006


PatchSet 7153 
Date: 2006/03/19 16:16:15
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Fix for bug #14

	* kaffe/kaffevm/classMethod.c,
	kaffe/kaffevm/reference.c,
	kaffe/kaffevm/support.c,
	kaffe/kaffevm/jni/jni.c: Adapted to new internal API.

	* kaffe/kaffevm/lookup.c,
	kaffe/kaffevm/lookup.h
	(KaffeVM_findDeclaredMethod): New function to lookup for methods
	declared in the specified class only.

	* kaffe/kaffevm/support.c
	(lookupClassMethod): New parameter to specify if we want the
	declared methods or not.

Members: 
	ChangeLog:1.4671->1.4672 
	kaffe/kaffevm/classMethod.c:1.151->1.152 
	kaffe/kaffevm/lookup.c:1.47->1.48 
	kaffe/kaffevm/lookup.h:1.6->1.7 
	kaffe/kaffevm/reference.c:1.7->1.8 
	kaffe/kaffevm/support.c:1.91->1.92 
	kaffe/kaffevm/support.h:1.44->1.45 
	kaffe/kaffevm/jni/jni.c:1.40->1.41 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4671 kaffe/ChangeLog:1.4672
--- kaffe/ChangeLog:1.4671	Sat Mar 18 17:40:16 2006
+++ kaffe/ChangeLog	Sun Mar 19 16:16:15 2006
@@ -1,4 +1,22 @@
-2006-03-16  Guilhem Lavaux  <guilhem at kaffe.org>
+2006-03-19  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	Fix for bug #14
+	
+	* kaffe/kaffevm/classMethod.c,
+	kaffe/kaffevm/reference.c,
+	kaffe/kaffevm/support.c,
+	kaffe/kaffevm/jni/jni.c: Adapted to new internal API.
+
+	* kaffe/kaffevm/lookup.c,
+	kaffe/kaffevm/lookup.h
+	(KaffeVM_findDeclaredMethod): New function to lookup for methods
+	declared in the specified class only.
+
+	* kaffe/kaffevm/support.c
+	(lookupClassMethod): New parameter to specify if we want the
+	declared methods or not.
+	
+2006-03-18  Guilhem Lavaux  <guilhem at kaffe.org>
 
 	* config/i386/cygwin32/md.h
 	(ALIGNMENT_OF_SIZE): Redefine it specifically for cygwin.
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.151 kaffe/kaffe/kaffevm/classMethod.c:1.152
--- kaffe/kaffe/kaffevm/classMethod.c:1.151	Mon Dec 26 20:06:34 2005
+++ kaffe/kaffe/kaffevm/classMethod.c	Sun Mar 19 16:16:21 2006
@@ -1403,7 +1403,7 @@
 	     */
 	    if ((meth = lookupClassMethod(class_of_loader, "loadClass", 
 					 "(Ljava/lang/String;)Ljava/lang/Class;",
-					 einfo)) == NULL)
+					  false, einfo)) == NULL)
 	      {
 		retval = NULL;
 		goto userload_done;
Index: kaffe/kaffe/kaffevm/lookup.c
diff -u kaffe/kaffe/kaffevm/lookup.c:1.47 kaffe/kaffe/kaffevm/lookup.c:1.48
--- kaffe/kaffe/kaffevm/lookup.c:1.47	Mon May 30 09:24:00 2005
+++ kaffe/kaffe/kaffevm/lookup.c	Sun Mar 19 16:16:21 2006
@@ -366,3 +366,31 @@
 	postExceptionMessage(einfo, JAVA_LANG(NoSuchMethodError), "%s", name->data);
 	return (NULL);
 }
+
+
+Method*
+KaffeVM_findDeclaredMethod(Hjava_lang_Class *class, Utf8Const *name, Utf8Const *signature, errorInfo *einfo)
+{
+  Method *mptr;
+  bool success;
+  /*
+   * Waz CSTATE_LINKED - Must resolve constants before we do any
+   * translation.  Might not be right though ... XXX
+   */
+  if (class->state < CSTATE_USABLE) {
+    success = processClass(class, CSTATE_COMPLETE, einfo);
+    if (!success)
+      return (NULL);
+  }
+
+  /*
+   * Lookup method - this could be alot more efficient but never mind.
+   * Also there is no attempt to honour PUBLIC, PRIVATE, etc.
+   */
+  mptr = findMethodLocal(class, name, signature);
+  if (mptr != NULL)
+    return mptr;
+
+  postExceptionMessage(einfo, JAVA_LANG(NoSuchMethodError), "%s", name->data);
+  return NULL;
+}
Index: kaffe/kaffe/kaffevm/lookup.h
diff -u kaffe/kaffe/kaffevm/lookup.h:1.6 kaffe/kaffe/kaffevm/lookup.h:1.7
--- kaffe/kaffe/kaffevm/lookup.h:1.6	Fri Oct  1 20:39:41 1999
+++ kaffe/kaffe/kaffevm/lookup.h	Sun Mar 19 16:16:21 2006
@@ -45,5 +45,6 @@
 
 Method* findMethod(Hjava_lang_Class*, Utf8Const*, Utf8Const*, errorInfo*);
 Method* findMethodLocal(Hjava_lang_Class*, Utf8Const*, Utf8Const*);
+Method* KaffeVM_findDeclaredMethod(Hjava_lang_Class*, Utf8Const*, Utf8Const*, errorInfo*);
 
 #endif
Index: kaffe/kaffe/kaffevm/reference.c
diff -u kaffe/kaffe/kaffevm/reference.c:1.7 kaffe/kaffe/kaffevm/reference.c:1.8
--- kaffe/kaffe/kaffevm/reference.c:1.7	Fri May  6 15:24:28 2005
+++ kaffe/kaffe/kaffevm/reference.c	Sun Mar 19 16:16:21 2006
@@ -175,7 +175,7 @@
       referenceLinkList *temp = ll->next;
       errorInfo einfo;
       Hjava_lang_Class *ref_clazz = OBJECT_CLASS((Hjava_lang_Object*)ll->reference);
-      Method *mid = lookupClassMethod(ref_clazz, "enqueue", "()Z", &einfo);
+      Method *mid = lookupClassMethod(ref_clazz, "enqueue", "()Z", false, &einfo);
 
       if (mid != NULL && !METHOD_IS_STATIC(mid))
 	{
Index: kaffe/kaffe/kaffevm/support.c
diff -u kaffe/kaffe/kaffevm/support.c:1.91 kaffe/kaffe/kaffevm/support.c:1.92
--- kaffe/kaffe/kaffevm/support.c:1.91	Fri Dec 16 19:56:55 2005
+++ kaffe/kaffe/kaffevm/support.c	Sun Mar 19 16:16:21 2006
@@ -103,7 +103,7 @@
 		assert(method_name != NULL);
 		assert(signature != NULL);
 		if (isStaticCall) {
-			mb = lookupClassMethod((Hjava_lang_Class*)obj, method_name, signature, &info);
+			mb = lookupClassMethod((Hjava_lang_Class*)obj, method_name, signature, false, &info);
 		}
 		else {
 			mb = lookupObjectMethod((Hjava_lang_Object*)obj, method_name, signature, &info);
@@ -179,7 +179,7 @@
 
 	/* Get method */
 	if (clazz != NULL) {
-		mb = lookupClassMethod(clazz, method_name, signature, &info);
+		mb = lookupClassMethod(clazz, method_name, signature, false, &info);
 	}
 	if (mb == NULL) {
 		throwError(&info);
@@ -367,7 +367,7 @@
  * @return struct _jmethodID of the method being searched or 0 in case of an error
  */
 Method*
-lookupClassMethod(Hjava_lang_Class* cls, const char* name, const char* sig, errorInfo *einfo)
+lookupClassMethod(Hjava_lang_Class* cls, const char* name, const char* sig, bool declared, errorInfo *einfo)
 {
 	Method *meth;
 	Utf8Const *name_utf8, *sig_utf8;
@@ -387,7 +387,10 @@
 		postOutOfMemory(einfo);
 		return NULL;
 	}
-	meth = findMethod(cls, name_utf8, sig_utf8, einfo);
+	if (declared)
+	  meth = KaffeVM_findDeclaredMethod(cls, name_utf8, sig_utf8, einfo);
+	else
+	  meth = findMethod(cls, name_utf8, sig_utf8, einfo);
 	utf8ConstRelease(name_utf8);
 	utf8ConstRelease(sig_utf8);
 	return(meth);
@@ -407,7 +410,7 @@
 lookupObjectMethod(Hjava_lang_Object* obj, const char* name, const char* sig, errorInfo *einfo)
 {
 	assert(obj != NULL && name != NULL && sig != NULL);
-	return (lookupClassMethod(OBJECT_CLASS(obj), name, sig, einfo));
+	return (lookupClassMethod(OBJECT_CLASS(obj), name, sig, false, einfo));
 }
 
 /**
Index: kaffe/kaffe/kaffevm/support.h
diff -u kaffe/kaffe/kaffevm/support.h:1.44 kaffe/kaffe/kaffevm/support.h:1.45
--- kaffe/kaffe/kaffevm/support.h:1.44	Fri Dec 16 19:56:55 2005
+++ kaffe/kaffe/kaffevm/support.h	Sun Mar 19 16:16:21 2006
@@ -135,7 +135,7 @@
 extern void	KaffeVM_callMethodV(struct _jmethodID*, void*, void*, va_list, jvalue*);
 extern void     KaffeVM_safeCallMethodA(struct _jmethodID*, void*, void*, jvalue*, jvalue*, int);
 extern void     KaffeVM_safeCallMethodV(struct _jmethodID*, void*, void*, va_list, jvalue*);
-extern Method*	lookupClassMethod(struct Hjava_lang_Class*, const char*, const char*, struct _errorInfo*);
+extern Method*	lookupClassMethod(struct Hjava_lang_Class*, const char*, const char*, bool, struct _errorInfo*);
 extern Method*	lookupObjectMethod(struct Hjava_lang_Object*, const char*, const char*, struct _errorInfo*);
 extern Field*   KNI_lookupFieldC(struct Hjava_lang_Class*, const char*, bool, struct _errorInfo*);
 
Index: kaffe/kaffe/kaffevm/jni/jni.c
diff -u kaffe/kaffe/kaffevm/jni/jni.c:1.40 kaffe/kaffe/kaffevm/jni/jni.c:1.41
--- kaffe/kaffe/kaffevm/jni/jni.c:1.40	Sat Mar  4 17:51:07 2006
+++ kaffe/kaffe/kaffevm/jni/jni.c	Sun Mar 19 16:16:22 2006
@@ -536,7 +536,7 @@
 	cls_local = unveil(cls);
 
 	meth = lookupClassMethod((Hjava_lang_Class*)cls_local, name, sig,
-				 &info);
+				 false, &info);
 	if (meth == NULL) {
 		postError(env, &info);
 	}
@@ -585,7 +585,7 @@
 
 	cls_local = unveil(cls);
 	meth = lookupClassMethod((Hjava_lang_Class*)cls_local, name, sig,
-				 &info);
+				 true, &info);
 	if (meth == NULL) {
 		postError(env, &info);
 	} else if (!METHOD_IS_STATIC(meth)) {




More information about the kaffe mailing list