aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/security/SecureClassLoader.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/security/SecureClassLoader.java')
-rw-r--r--libjava/java/security/SecureClassLoader.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/libjava/java/security/SecureClassLoader.java b/libjava/java/security/SecureClassLoader.java
index 7546edc85e5..89b5e4effce 100644
--- a/libjava/java/security/SecureClassLoader.java
+++ b/libjava/java/security/SecureClassLoader.java
@@ -48,6 +48,8 @@ package java.security;
*/
public class SecureClassLoader extends ClassLoader
{
+ java.util.WeakHashMap protectionDomainCache = new java.util.WeakHashMap();
+
protected SecureClassLoader(ClassLoader parent)
{
super(parent);
@@ -80,11 +82,29 @@ public class SecureClassLoader extends ClassLoader
protected final Class defineClass(String name, byte[] b, int off, int len,
CodeSource cs)
{
- // FIXME: Need to cache ProtectionDomains according to 1.3 docs.
if (cs != null)
{
- ProtectionDomain protectionDomain
- = new ProtectionDomain(cs, getPermissions(cs), this, null);
+ ProtectionDomain protectionDomain;
+
+ synchronized (protectionDomainCache)
+ {
+ protectionDomain = (ProtectionDomain)protectionDomainCache.get(cs);
+ }
+
+ if (protectionDomain == null)
+ {
+ protectionDomain
+ = new ProtectionDomain(cs, getPermissions(cs), this, null);
+ synchronized (protectionDomainCache)
+ {
+ ProtectionDomain domain
+ = (ProtectionDomain)protectionDomainCache.get(cs);
+ if (domain == null)
+ protectionDomainCache.put(cs, protectionDomain);
+ else
+ protectionDomain = domain;
+ }
+ }
return super.defineClass(name, b, off, len, protectionDomain);
}
else