Re: Method.invoke() on a non-public class from another package

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2007-04-08 at 23:12 +0200, Mark Wielaard wrote:
> Attached is a simplified test case (3 classes - c1 is in package p1, c2
> and c3 are in package p2, c2 is not public, p1.c1 is the entry point)
> that should throw an IllegalAccessException on the line:
>   m.invoke(o, new Object[0]);

Sun's RI throws this exception:

Exception in thread "main" java.lang.IllegalAccessException: Class p1.c1 can not access a member of class p2.c2 with modifiers "public"
        at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
        at java.lang.reflect.Method.invoke(Method.java:588)
        at p1.c1.main(c1.java:10)

Maybe we should also implement some access checks in classpath itself,
as Sun does in sun.reflect.Reflection.ensureMemberAccess, before we call
invokeNative?

- twisti


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux