harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r370812 - in /incubator/harmony/enhanced/jchevm/libjc: definitions.h resolve.c
Date Fri, 20 Jan 2006 14:21:11 GMT
Author: archie
Date: Fri Jan 20 06:21:05 2006
New Revision: 370812

URL: http://svn.apache.org/viewcvs?rev=370812&view=rev
Log:
- Fix bug in method resolution: we were not finding methods declared in
  interfaces implemented by superclasses.
- Add _JC_EX_RESET() macro for resetting any stored exception; does
  nothing when assertions are disabled.

Modified:
    incubator/harmony/enhanced/jchevm/libjc/definitions.h
    incubator/harmony/enhanced/jchevm/libjc/resolve.c

Modified: incubator/harmony/enhanced/jchevm/libjc/definitions.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/definitions.h?rev=370812&r1=370811&r2=370812&view=diff
==============================================================================
--- incubator/harmony/enhanced/jchevm/libjc/definitions.h (original)
+++ incubator/harmony/enhanced/jchevm/libjc/definitions.h Fri Jan 20 06:21:05 2006
@@ -564,6 +564,15 @@
 	snprintf(_env->ex.msg, sizeof(_env->ex.msg), fmt , ## args);	\
     } while (0)
 
+#ifndef NDEBUG
+#define _JC_EX_RESET(env)						\
+    do {								\
+	(env)->ex.num = -1;						\
+    } while (0)
+#else
+#define _JC_EX_RESET(env)	do { } while (0)
+#endif
+
 /*
  * Allocate some memory on the stack, and throw a StackOverflowError
  * if that fails. This does not directly check for stack overflow, which

Modified: incubator/harmony/enhanced/jchevm/libjc/resolve.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/jchevm/libjc/resolve.c?rev=370812&r1=370811&r2=370812&view=diff
==============================================================================
--- incubator/harmony/enhanced/jchevm/libjc/resolve.c (original)
+++ incubator/harmony/enhanced/jchevm/libjc/resolve.c Fri Jan 20 06:21:05 2006
@@ -254,25 +254,29 @@
 	clinit = strcmp(name, "<clinit>") == 0;
 
 	/* Search for method in class and superclasses */
-	for (stype = type; stype != NULL; ) {
+	for (stype = type; stype != NULL; stype = stype->superclass) {
 		if ((method = _jc_get_declared_method(env,
 		    stype, name, sig, 0, 0)) != NULL)
 			return method;
 		if (clinit)
 			return NULL;
-		stype = stype->superclass;
+		_JC_EX_RESET(env);
 	}
 
-	/* Search for method in superinterfaces */
-	for (i = 0; i < type->num_interfaces; i++) {
-		_jc_type *const itype = type->interfaces[i];
+	/* Search for method in all implemented interfaces */
+	for (stype = type; stype != NULL; stype = stype->superclass) {
+		for (i = 0; i < stype->num_interfaces; i++) {
+			_jc_type *const itype = stype->interfaces[i];
 
-		if ((method = _jc_resolve_method(env,
-		    itype, name, sig)) != NULL)
-			return method;
+			if ((method = _jc_resolve_method(env,
+			    itype, name, sig)) != NULL)
+				return method;
+			_JC_EX_RESET(env);
+		}
 	}
 
 	/* Not found */
+	_JC_EX_STORE(env, NoSuchMethodError, "%s.%s%s", type->name, name, sig);
 	return NULL;
 }
 



Mime
View raw message