[kaffe] Should IllegalAccessException be thrown or not?

Ito Kazumitsu kaz at maczuka.gcd.org
Sun Dec 11 18:35:59 PST 2005


From: Ito Kazumitsu <kaz at maczuka.gcd.org>
Date: Sun, 11 Dec 2005 10:51:52 +0900 (JST)

> The next test case will illustrate this problem more clearly.
> 
> $ cat A.java
> public class A {
>         public static void main(String[] args) {
>             try {
>                 B.getPrivateClass().newInstance();
>             }
>             catch (Exception e) {
>                 e.printStackTrace();
>             }
>         }
> 
> }
> $ cat B.java
> public class B {
>     private static class PrivateClass {}
>     public static Class getPrivateClass() { return PrivateClass.class; }
> }
> 
> In this case, Sun's JDK throws IllegalAccessException as expected.
> But Kaffe does not.

kaffe/kaffevm/access.c has this code:

   261          else if( same_package && !(target_flags & ACC_PRIVATE) )
   262          {
   263                  /* Package. */
   264                  slot_acc = 1;
   265          }

I am afraid this makes anything private in the target class T
accessible to the caller C if T and C are in the same package
and T is accessible to C.




More information about the kaffe mailing list