nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/ClassMap.java
changeset 33336 47279b2180b4
parent 33330 35531ae624ef
child 33337 af3fea63e008
equal deleted inserted replaced
33335:a46c85103868 33336:47279b2180b4
   148         }
   148         }
   149         // Not found in either place; create a new value
   149         // Not found in either place; create a new value
   150         final T newV = computeValue(clazz);
   150         final T newV = computeValue(clazz);
   151         assert newV != null;
   151         assert newV != null;
   152 
   152 
   153         final ClassLoader clazzLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
   153         final Boolean canReferenceDirectly = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
   154             @Override
   154             @Override
   155             public ClassLoader run() {
   155             public Boolean run() {
   156                 return clazz.getClassLoader();
   156                 return Guards.canReferenceDirectly(classLoader, clazz.getClassLoader());
   157             }
   157             }
   158         }, ClassLoaderGetterContextProvider.GET_CLASS_LOADER_CONTEXT);
   158         }, ClassLoaderGetterContextProvider.GET_CLASS_LOADER_CONTEXT);
   159 
   159 
   160         // If allowed to strongly reference, put it in the fast map
   160         // If allowed to strongly reference, put it in the fast map
   161         if(Guards.canReferenceDirectly(classLoader, clazzLoader)) {
   161         if(canReferenceDirectly) {
   162             final T oldV = map.putIfAbsent(clazz, newV);
   162             final T oldV = map.putIfAbsent(clazz, newV);
   163             return oldV != null ? oldV : newV;
   163             return oldV != null ? oldV : newV;
   164         }
   164         }
   165         // Otherwise, put it into the weak map
   165         // Otherwise, put it into the weak map
   166         synchronized(weakMap) {
   166         synchronized(weakMap) {