diff options
author | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-04-16 13:44:59 +0000 |
---|---|---|
committer | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-04-16 13:44:59 +0000 |
commit | 29b881f4d32c3bc9b1eb6ff9fbf786bd6ce49ae7 (patch) | |
tree | 596031af669670b840c0e1c7fc4b9cbcb65204c7 /libjava/java | |
parent | 29696c952e863db7de62992906bf178fb7bf60d5 (diff) | |
download | gcc-29b881f4d32c3bc9b1eb6ff9fbf786bd6ce49ae7.tar.gz |
2007-04-16 Andrew Haley <aph@redhat.com>
* gnu/gcj/runtime/BootClassLoader.java (getBootURLLoader): New
method.
(bootGetResource): Use getBootURLLoader() to load resources.
(bootGetResources): Likewise.
* java/lang/reflect/natMethod.cc (Method::invoke): In invoke also
check that the method's declaring class is accessible.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123862 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/reflect/natMethod.cc | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 6dcd4ec518a..4593da7f49e 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -173,16 +173,34 @@ java::lang::reflect::Method::invoke (jobject obj, jobjectArray args) } // Check accessibility, if required. - if (! (Modifier::isPublic (meth->accflags) || this->isAccessible())) + if (! this->isAccessible()) { - Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$); - if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags)) - throw new IllegalAccessException; + if (! (Modifier::isPublic (meth->accflags))) + { + Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$); + if (! _Jv_CheckAccess(caller, declaringClass, meth->accflags)) + throw new IllegalAccessException; + } + else + // Method is public, check to see if class is accessible. + { + jint flags = (declaringClass->accflags + & (Modifier::PUBLIC + | Modifier::PROTECTED + | Modifier::PRIVATE)); + if (flags == 0) // i.e. class is package private + { + Class *caller = _Jv_StackTrace::GetCallingClass (&Method::class$); + if (! _Jv_ClassNameSamePackage (caller->name, + declaringClass->name)) + throw new IllegalAccessException; + } + } } if (declaringClass->isInterface()) iface = declaringClass; - + return _Jv_CallAnyMethodA (obj, return_type, meth, false, parameter_types, args, iface); } |