summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
+ }
+ }
}
/**