1.1 --- a/src/jdk/internal/dynalink/support/ClassMap.java Thu Aug 01 12:23:38 2013 +0200 1.2 +++ b/src/jdk/internal/dynalink/support/ClassMap.java Wed Aug 07 16:38:44 2013 +0200 1.3 @@ -85,6 +85,8 @@ 1.4 1.5 import java.lang.ref.Reference; 1.6 import java.lang.ref.SoftReference; 1.7 +import java.security.AccessController; 1.8 +import java.security.PrivilegedAction; 1.9 import java.util.Map; 1.10 import java.util.WeakHashMap; 1.11 import java.util.concurrent.ConcurrentHashMap; 1.12 @@ -122,21 +124,12 @@ 1.13 protected abstract T computeValue(Class<?> clazz); 1.14 1.15 /** 1.16 - * Returns the class loader that governs the strong referenceability of this class map. 1.17 - * 1.18 - * @return the class loader that governs the strong referenceability of this class map. 1.19 - */ 1.20 - public ClassLoader getClassLoader() { 1.21 - return classLoader; 1.22 - } 1.23 - 1.24 - /** 1.25 * Returns the value associated with the class 1.26 * 1.27 * @param clazz the class 1.28 * @return the value associated with the class 1.29 */ 1.30 - public T get(Class<?> clazz) { 1.31 + public T get(final Class<?> clazz) { 1.32 // Check in fastest first - objects we're allowed to strongly reference 1.33 final T v = map.get(clazz); 1.34 if(v != null) { 1.35 @@ -156,8 +149,16 @@ 1.36 // Not found in either place; create a new value 1.37 final T newV = computeValue(clazz); 1.38 assert newV != null; 1.39 + 1.40 + final ClassLoader clazzLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { 1.41 + @Override 1.42 + public ClassLoader run() { 1.43 + return clazz.getClassLoader(); 1.44 + } 1.45 + }); 1.46 + 1.47 // If allowed to strongly reference, put it in the fast map 1.48 - if(Guards.canReferenceDirectly(classLoader, clazz.getClassLoader())) { 1.49 + if(Guards.canReferenceDirectly(classLoader, clazzLoader)) { 1.50 final T oldV = map.putIfAbsent(clazz, newV); 1.51 return oldV != null ? oldV : newV; 1.52 }