diff options
author | Andrew Haley <aph@redhat.com> | 2006-11-28 09:27:42 +0000 |
---|---|---|
committer | Andrew Haley <aph@redhat.com> | 2006-11-28 09:27:42 +0000 |
commit | f40b961c6c82ebc9ae9863635e5fe19c0b07c116 (patch) | |
tree | 7c2628d6d7ca8c24511988587c9e0e85ab821f88 /vm/reference/sun/reflect/misc/ReflectUtil.java | |
parent | 3c70e828350bdba0a3703211f312ae0f7f170df0 (diff) | |
download | classpath-f40b961c6c82ebc9ae9863635e5fe19c0b07c116.tar.gz |
2006-11-28 Andrew Haley <aph@redhat.com>
* vm/reference/sun/reflect/misc/ReflectUtil.java
(checkPackageAccess): Implement.
Diffstat (limited to 'vm/reference/sun/reflect/misc/ReflectUtil.java')
-rw-r--r-- | vm/reference/sun/reflect/misc/ReflectUtil.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/vm/reference/sun/reflect/misc/ReflectUtil.java b/vm/reference/sun/reflect/misc/ReflectUtil.java index 547427748..88a6f2515 100644 --- a/vm/reference/sun/reflect/misc/ReflectUtil.java +++ b/vm/reference/sun/reflect/misc/ReflectUtil.java @@ -51,9 +51,29 @@ public class ReflectUtil { } + /** + * Check if the current thread is allowed to access the package of + * the declaringClass. + * + * @param declaringClass class name to check access to + * @throws SecurityException if permission is denied + * @throws NullPointerException if declaringClass is null + */ public static void checkPackageAccess(Class declaringClass) { - // FIXME: not sure what to check here. + SecurityManager sm; + if ((sm = System.getSecurityManager()) != null) + { + while (declaringClass.isArray()) + declaringClass = declaringClass.getComponentType(); + String name = declaringClass.getName(); + int i = name.lastIndexOf('.'); + if (i != -1) // if declaringClass is a member of a package + { + name = name.substring(0, i); + sm.checkPackageAccess(name); + } + } } /** |