diff options
Diffstat (limited to 'libjava/java/lang/ClassLoader.java')
-rw-r--r-- | libjava/java/lang/ClassLoader.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index 5ae70cdb..008a19e 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -162,12 +162,10 @@ public abstract class ClassLoader SecurityManager sm = System.getSecurityManager(); if (sm != null) { - /* FIXME: security, getClassContext() not implemented. Class c = VMSecurityManager.getClassContext()[1]; ClassLoader cl = c.getClassLoader(); - if (cl != null && cl != this) + if (cl != null && ! cl.isAncestorOf(this)) sm.checkPermission(new RuntimePermission("getClassLoader")); - */ } return parent; } @@ -996,4 +994,20 @@ public abstract class ClassLoader packageAssertionStatus = new HashMap(); classAssertionStatus = new HashMap(); } + + /** + * Return true if this loader is either the specified class loader + * or an ancestor thereof. + * @param loader the class loader to check + */ + final boolean isAncestorOf(ClassLoader loader) + { + while (loader != null) + { + if (this == loader) + return true; + loader = loader.parent; + } + return false; + } } |