[kaffe] CVS kaffe (kaz): kaffe/kaffevm/access.c:

Kaffe CVS cvs-commits at kaffe.org
Mon Nov 17 07:39:01 PST 2003


PatchSet 4165 
Date: 2003/11/17 15:32:38
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
        * kaffe/kaffevm/access.c:
        (checkAccess) corrected to avoid java.lang.IllegalAccessError
        using new function recursive_instanceof.

Members: 
	ChangeLog:1.1757->1.1758 
	kaffe/kaffevm/access.c:1.5->1.6 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1757 kaffe/ChangeLog:1.1758
--- kaffe/ChangeLog:1.1757	Thu Nov 13 13:54:52 2003
+++ kaffe/ChangeLog	Mon Nov 17 15:32:38 2003
@@ -1,3 +1,9 @@
+2003-11-17  Ito Kazumitsu  <kaz at maczuka.gcd.org>
+
+	* kaffe/kaffevm/access.c:
+	(checkAccess) corrected to avoid java.lang.IllegalAccessError
+	using new function recursive_instanceof.
+
 2003-11-13  Dalibor Topic <robilad at kaffe.org>
 
 	* config/config.alias:
Index: kaffe/kaffe/kaffevm/access.c
diff -u kaffe/kaffe/kaffevm/access.c:1.5 kaffe/kaffe/kaffevm/access.c:1.6
--- kaffe/kaffe/kaffevm/access.c:1.5	Wed Nov 12 15:17:14 2003
+++ kaffe/kaffe/kaffevm/access.c	Mon Nov 17 15:32:40 2003
@@ -92,6 +92,44 @@
 	return( retval );
 }
 
+/*
+ * Returns 1 if oc is an instance of c or the superclass of c ...
+ */
+static
+int recursive_instanceof(Hjava_lang_Class *c, Hjava_lang_Class *oc)
+{
+	if ( instanceof(c, oc) )
+	{
+		return 1;
+	}
+	else
+	{
+       		innerClass *ic;
+		Hjava_lang_Class *outer;
+		errorInfo einfo;
+		ic = NULL;
+		outer = NULL;
+
+	       	if( oc->this_inner_index >= 0 )
+		{
+			ic = &oc->inner_classes[oc->this_inner_index];
+			if( ic->outer_class )
+			{
+				outer = getClass(ic->outer_class, oc, &einfo);
+				if( outer == NULL )
+				{
+					discardErrorInfo(&einfo);
+				}
+			}
+		}
+		if ( outer != NULL )
+		{
+			return recursive_instanceof(c, outer);
+		}
+		return 0;
+	}
+}
+
 int checkAccess(struct Hjava_lang_Class *context,
 		struct Hjava_lang_Class *target,
 		accessFlags target_flags)
@@ -154,21 +192,23 @@
 			}
 		}
 
-		if( outert != NULL )
+		if( outerc != NULL )
 		{
-			if( instanceof(outert, context) )
-		       	{
+			if ( recursive_instanceof(target, outerc) )
+			{
 				class_acc = 1;
 			}
-			else if (outerc != NULL)
+			else if (outert != NULL)
 			{
-				class_acc = instanceof(outert, outerc);
+				class_acc = recursive_instanceof(outert, outerc);
 			}
+
 		}
-		else if( outerc != NULL )
+		else if ( outert != NULL )
 		{
-			class_acc = instanceof(target, outerc);
+			class_acc = instanceof(outert, context);
 		}
+
 	}
 	
 	if((context->packageLength == target->packageLength) &&




More information about the kaffe mailing list