static synchronized Class getMethodInvocationClass()

in javassist/src/main/java/org/apache/commons/proxy2/javassist/JavassistInvocation.java [166:191]


    static synchronized Class<?> getMethodInvocationClass(ClassLoader classLoader, Method interfaceMethod)
            throws CannotCompileException
    {
        final Map<String, WeakReference<Class<?>>> classCache = getClassCache(classLoader);
        final String key = toClassCacheKey(interfaceMethod);
        final WeakReference<Class<?>> invocationClassRef = classCache.get(key);
        Class<?> invocationClass;
        if (invocationClassRef == null)
        {
            invocationClass = createInvocationClass(classLoader, interfaceMethod);
            classCache.put(key, new WeakReference<Class<?>>(invocationClass));
        }
        else
        {
            synchronized (invocationClassRef)
            {
                invocationClass = invocationClassRef.get();
                if (invocationClass == null)
                {
                    invocationClass = createInvocationClass(classLoader, interfaceMethod);
                    classCache.put(key, new WeakReference<Class<?>>(invocationClass));
                }
            }
        }
        return invocationClass;
    }