summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Haley <aph@redhat.com>2006-11-28 09:27:42 +0000
committerAndrew Haley <aph@redhat.com>2006-11-28 09:27:42 +0000
commitf40b961c6c82ebc9ae9863635e5fe19c0b07c116 (patch)
tree7c2628d6d7ca8c24511988587c9e0e85ab821f88
parent3c70e828350bdba0a3703211f312ae0f7f170df0 (diff)
downloadclasspath-f40b961c6c82ebc9ae9863635e5fe19c0b07c116.tar.gz
2006-11-28 Andrew Haley <aph@redhat.com>
* vm/reference/sun/reflect/misc/ReflectUtil.java (checkPackageAccess): Implement.
-rw-r--r--ChangeLog5
-rw-r--r--vm/reference/sun/reflect/misc/ReflectUtil.java22
2 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index cb214e8d5..1ac124999 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-11-28 Andrew Haley <aph@redhat.com>
+
+ * vm/reference/sun/reflect/misc/ReflectUtil.java
+ (checkPackageAccess): Implement.
+
2006-11-27 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/lang/Enum.java:
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);
+ }
+ }
}
/**