diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2007-01-09 19:58:05 +0000 |
commit | 97b8365cafc3a344a22d3980b8ed885f5c6d8357 (patch) | |
tree | 996a5f57d4a68c53473382e45cb22f574cb3e4db /libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java | |
parent | c648dedbde727ca3f883bb5fd773aa4af70d3369 (diff) | |
download | gcc-97b8365cafc3a344a22d3980b8ed885f5c6d8357.tar.gz |
Merged gcj-eclipse branch to trunk.
From-SVN: r120621
Diffstat (limited to 'libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java')
-rw-r--r-- | libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java b/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java index aa89c50ac9b..88a6f2515bf 100644 --- a/libjava/classpath/vm/reference/sun/reflect/misc/ReflectUtil.java +++ b/libjava/classpath/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); + } + } } /** @@ -64,6 +84,7 @@ public class ReflectUtil * @param declarer the declaring class of the member * @param ignored unknown parameter; always null * @param modifiers the modifiers on the member + * @return true if access is granted, false otherwise */ public static void ensureMemberAccess(Class caller, Class declarer, |