diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-27 04:07:48 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-27 04:07:48 +0000 |
commit | 63fd4522bbcb6d04a5263ad9c2b36ea14f59eb12 (patch) | |
tree | 55d0346a0f02ec766a2f9727307c6ef34124d6ac /libjava/java/lang/Thread.java | |
parent | 40000b13d53cd26333206c29a058da6227a6df03 (diff) | |
download | ppe42-gcc-63fd4522bbcb6d04a5263ad9c2b36ea14f59eb12.tar.gz ppe42-gcc-63fd4522bbcb6d04a5263ad9c2b36ea14f59eb12.zip |
* Makefile.in: Rebuilt.
* Makefile.am (core_java_source_files): Added
RuntimePermission.java.
* java/lang/RuntimePermission.java: Imported from Classpath.
* java/lang/Thread.java (getContextClassLoader): Now
synchronized. Added security code.
(setContextClassLoader): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37772 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/lang/Thread.java')
-rw-r--r-- | libjava/java/lang/Thread.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java index 33fabf4b5ac..12c7eb6cb45 100644 --- a/libjava/java/lang/Thread.java +++ b/libjava/java/lang/Thread.java @@ -145,21 +145,37 @@ public class Thread implements Runnable daemon_flag = status; } - public ClassLoader getContextClassLoader() + public synchronized ClassLoader getContextClassLoader() { if (context_class_loader == null) + context_class_loader = ClassLoader.getSystemClassLoader (); + + SecurityManager s = System.getSecurityManager(); + // FIXME: we can't currently find the caller's class loader. + ClassLoader callers = null; + if (s != null && callers != null) { - context_class_loader = ClassLoader.getSystemClassLoader (); - return context_class_loader; + // See if the caller's class loader is the same as or an + // ancestor of this thread's class loader. + while (callers != null && callers != context_class_loader) + { + // FIXME: should use some internal version of getParent + // that avoids security checks. + callers = callers.getParent (); + } + + if (callers != context_class_loader) + s.checkPermission (new RuntimePermission ("getClassLoader")); } - // FIXME: Add security manager stuff here. return context_class_loader; } - public void setContextClassLoader(ClassLoader cl) + public synchronized void setContextClassLoader(ClassLoader cl) { - // FIXME: Add security manager stuff here. + SecurityManager s = System.getSecurityManager (); + if (s != null) + s.checkPermission (new RuntimePermission ("setContextClassLoader")); context_class_loader = cl; } |