From: Ito Kazumitsu <[EMAIL PROTECTED]>
Date: Mon, 12 Dec 2005 15:21:26 +0900 (JST)

> But I am afraid
> 
>    266          else if( (target->name->data[0] != '[') &&
>    267                   same_package &&
>    268                   (target->this_inner_index >= 0) )
>    269          {
>    270                  slot_acc = 1;
>    271          }
> 
> will make something private in the target class T accessible to
> the caller C if T and C are in the same package and T is a nested
> class.

How about this patch?

--- kaffe/kaffevm/access.c.orig Fri Aug 19 15:00:41 2005
+++ kaffe/kaffevm/access.c      Mon Dec 12 16:37:15 2005
@@ -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)
@@ -236,6 +275,14 @@
                }
 
        }
+       else if ( outerof(target, context) )
+       {
+               /* target is within the context. */
+               class_acc = 1;
+               slot_acc = 1;
+
+               return 1;
+       }
        
        if((context->packageLength == target->packageLength) &&
            !strncmp(context->name->data,
@@ -263,12 +310,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
kaffe@kaffe.org
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to