PatchSet 7001 
Date: 2005/12/13 15:08:29
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2005-12-13  Ito Kazumitsu  <[EMAIL PROTECTED]>

        * kaffe/kaffevm/access.c
        (outerof): New function,
        (checkAccess): Corrected the handling of private access.

Members: 
        ChangeLog:1.4522->1.4523 
        kaffe/kaffevm/access.c:1.12->1.13 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4522 kaffe/ChangeLog:1.4523
--- kaffe/ChangeLog:1.4522      Tue Dec 13 03:19:23 2005
+++ kaffe/ChangeLog     Tue Dec 13 15:08:29 2005
@@ -1,3 +1,9 @@
+2005-12-13  Ito Kazumitsu  <[EMAIL PROTECTED]>
+
+       * kaffe/kaffevm/access.c
+       (outerof): New function,
+       (checkAccess): Corrected the handling of private access.
+
 2005-12-13  Dalibor Topic  <[EMAIL PROTECTED]>
 
         * libraries/javalib/external/classpath: Resynched GNU Classpath.
Index: kaffe/kaffe/kaffevm/access.c
diff -u kaffe/kaffe/kaffevm/access.c:1.12 kaffe/kaffe/kaffevm/access.c:1.13
--- kaffe/kaffe/kaffevm/access.c:1.12   Fri Aug 19 00:38:31 2005
+++ kaffe/kaffe/kaffevm/access.c        Tue Dec 13 15:08:33 2005
@@ -116,7 +116,7 @@
 }
 
 /*
- * Returns 1 if oc is an instance of c or the superclass of c ...
+ * Returns 1 if oc or its outer class is an instance of c
  */
 static
 int recursive_instanceof(Hjava_lang_Class *c, Hjava_lang_Class *oc)
@@ -153,6 +153,45 @@
        }
 }
 
+/*
+ * Returns 1 if oc is an outer class of c
+ */
+static
+int outerof (Hjava_lang_Class *c, Hjava_lang_Class *oc)
+{
+       innerClass *ic;
+       Hjava_lang_Class *outer;
+       errorInfo einfo;
+
+       outer = NULL;
+               if( c->this_inner_index >= 0 )
+       {
+               ic = &c->inner_classes[c->this_inner_index];
+               if( ic->outer_class )
+               {
+                       outer = getClass(ic->outer_class, c, &einfo);
+                       if( outer == NULL )
+                       {
+                               discardErrorInfo(&einfo);
+                       }
+               }
+       }
+       if ( outer != NULL )
+       {
+               if ( oc == outer)
+               {
+                       return 1;
+               }
+               else
+               {
+                       return outerof(outer, oc);
+               }
+       }
+       else {
+               return 0;
+       }
+}
+
 int checkAccess(struct Hjava_lang_Class *context,
                struct Hjava_lang_Class *target,
                accessFlags target_flags)
@@ -170,6 +209,14 @@
 
                return 1;
        }
+       else if ( outerof(target, context) )
+       {
+               /* target is within the context. */
+               class_acc = 1;
+               slot_acc = 1;
+
+               return 1;
+       }
        else if( target->accflags & ACC_PUBLIC )
        {
                /* Public class. */
@@ -244,7 +291,10 @@
        {
                same_package = 1;
                /* Package */
-               class_acc = 1;
+               if (!(target->accflags & ACC_PROTECTED))
+               {
+                       class_acc = 1;
+               }
        }
 
        if( target_flags & ACC_PUBLIC )
@@ -263,12 +313,17 @@
                /* Package. */
                slot_acc = 1;
        }
+/*
+       Commented out because private members get accessible to
+       any context in the same package if target is a nested class.
+
        else if( (target->name->data[0] != '[') &&
                 same_package &&
                 (target->this_inner_index >= 0) )
        {
                slot_acc = 1;
        }
+*/
        else if( context->this_inner_index >= 0 )
        {
                innerClass *ic;

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to