PatchSet 4005 
Date: 2003/09/01 03:06:57
Author: stack
Branch: HEAD
Tag: (none) 
Log:
Fix inner->outer class access check

Members: 
        ChangeLog:1.1601->1.1602 
        kaffe/kaffevm/access.c:1.1->1.2 
        kaffe/kaffevm/classMethod.c:1.109->1.110 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1601 kaffe/ChangeLog:1.1602
--- kaffe/ChangeLog:1.1601      Sun Aug 31 23:13:33 2003
+++ kaffe/ChangeLog     Mon Sep  1 03:06:57 2003
@@ -1,3 +1,11 @@
+2003-08-31  Timothy S. Stack <[EMAIL PROTECTED]>
+
+       * kaffe/kaffevm/access.c:
+       Allow inner classes to access members in the outer class.
+
+       * kaffe/kaffevm/classMethod.c:
+       Fix initial value of this_inner_index in the class struct.
+
 2003-08-31  Ito Kazumitsu <[EMAIL PROTECTED]>
 
        * libraries/javalib/java/text/SimpleDateFormat.java:
Index: kaffe/kaffe/kaffevm/access.c
diff -u kaffe/kaffe/kaffevm/access.c:1.1 kaffe/kaffe/kaffevm/access.c:1.2
--- kaffe/kaffe/kaffevm/access.c:1.1    Sun Aug 31 22:09:01 2003
+++ kaffe/kaffe/kaffevm/access.c        Mon Sep  1 03:06:58 2003
@@ -97,7 +97,7 @@
                accessFlags target_flags)
 {
        int class_acc = 0, slot_acc = 0, same_package = 0;
-
+       
        assert(context);
        assert(target);
        
@@ -145,11 +145,44 @@
        }
        else if( (target->name->data[0] != '[') &&
                 same_package &&
-                target->this_inner_index )
+                (target->this_inner_index >= 0) )
        {
                slot_acc = 1;
        }
+       else if( context->this_inner_index >= 0 )
+       {
+               innerClass *ic;
 
+               /*
+                * Check for an inner class accessing something in the outer.
+                */
+               ic = &context->inner_classes[context->this_inner_index];
+               if( ic->outer_class )
+               {
+                       Hjava_lang_Class *outer;
+                       errorInfo einfo;
+                       
+                       outer = getClass(ic->outer_class, context, &einfo);
+                       if( outer != NULL )
+                       {
+                               if( (target_flags & ACC_PRIVATE) &&
+                                   (target == outer) )
+                               {
+                                       /* XXX Not sure about this. */
+                                       slot_acc = 1;
+                               }
+                               else if( (target_flags & ACC_PROTECTED) &&
+                                        instanceof(target, outer) )
+                               {
+                                       slot_acc = 1;
+                               }
+                       }
+                       else
+                       {
+                               discardErrorInfo(&einfo);
+                       }
+               }
+       }
        return( class_acc && slot_acc );
 }
 
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.109 kaffe/kaffe/kaffevm/classMethod.c:1.110
--- kaffe/kaffe/kaffevm/classMethod.c:1.109     Sun Aug 31 22:09:01 2003
+++ kaffe/kaffe/kaffevm/classMethod.c   Mon Sep  1 03:06:58 2003
@@ -974,6 +974,7 @@
        cl->this_index = this_index;
        cl->inner_classes = 0;
        cl->nr_inner_classes = 0;
+       cl->this_inner_index = -1;
        return 1;
 }
 
@@ -1073,7 +1074,7 @@
 
                if (c->this_index && ic->inner_class == c->this_index) {
                    c->accflags = (c->accflags & ~ACC_MASK) | 
(ic->inner_class_accflags & ACC_MASK);
-                   c->this_inner_index = nr;
+                   c->this_inner_index = i;
                }
        }
        return true;

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

Reply via email to