code: public static ClassLoader resolveClassLoaderForBeanProxy(String contextId, Class<?> proxiedType, TypeInfo typeInfo, ProxyServices proxyServices) {
          Class<?> superClass = typeInfo.getSuperClass();
          if (superClass.getName().startsWith(JAVA)) {
              ClassLoader cl = proxyServices.getClassLoader(proxiedType);
              if (cl == null) {
                  cl = Thread.currentThread().getContextClassLoader();
              }
              return cl;
          }
          return Container.instance(contextId).services().get(ProxyServices.class).getClassLoader(superClass);
      }
docs: Figures out the correct class loader to use for a proxy for a given bean