weld/subsystem/src/main/java/org/jboss/as/weld/services/bootstrap/ProxyServicesImpl.java
private Module getModule(Class<?> originalClass) {
        if (originalClass.getName().startsWith("java")) {
            return module;
        } else {
            Module definingModule = Module.forClass(originalClass);
            Boolean hasWeldDependencies = processedStaticModules.get(definingModule.getIdentifier());
            boolean logWarning = false; // only log for the first class in the module
            if (hasWeldDependencies == null) {
                hasWeldDependencies = canLoadWeldProxies(definingModule); // may be run multiple times but that does not matter
                logWarning = processedStaticModules.putIfAbsent(definingModule.getIdentifier(), hasWeldDependencies) == null;
            }
            if (hasWeldDependencies) {
                // this module declares Weld dependencies - we can use module's classloader to load the proxy class
                // pros: package-private members will work fine
                // cons: proxy classes will remain loaded by the module's classloader after undeployment (nothing else leaks)
                return definingModule;
            } else {
                // no weld dependencies - we use deployment's classloader to load the proxy class
                // pros: proxy classes unloaded with undeployment
                // cons: package-private methods and constructors will yield IllegalAccessException
                if (logWarning) {
                    WeldLogger.ROOT_LOGGER.loadingProxiesUsingDeploymentClassLoader(definingModule.getIdentifier(), Arrays.toString(REQUIRED_WELD_DEPENDENCIES));
                }
                return this.module;
            }
        }
    }
private Module getModule(Class<?> originalClass) {
        if (originalClass.getName().startsWith("java")) {
            return module;
        } else {
            Module definingModule = Module.forClass(originalClass);
            Boolean hasWeldDependencies = processedStaticModules.get(definingModule.getIdentifier());
            boolean logWarning = false; // only log for the first class in the module
            if (hasWeldDependencies == null) {
                hasWeldDependencies = canLoadWeldProxies(definingModule); // may be run multiple times but that does not matter
                logWarning = processedStaticModules.putIfAbsent(definingModule.getIdentifier(), hasWeldDependencies) == null;
            }
            if (hasWeldDependencies) {
                // this module declares Weld dependencies - we can use module's classloader to load the proxy class
                // pros: package-private members will work fine
                // cons: proxy classes will remain loaded by the module's classloader after undeployment (nothing else leaks)
                return definingModule;
            } else {
                // no weld dependencies - we use deployment's classloader to load the proxy class
                // pros: proxy classes unloaded with undeployment
                // cons: package-private methods and constructors will yield IllegalAccessException
                if (logWarning) {
                    WeldLogger.ROOT_LOGGER.loadingProxiesUsingDeploymentClassLoader(definingModule.getIdentifier(), Arrays.toString(REQUIRED_WELD_DEPENDENCIES));
                }
                return this.module;
            }
        }
    }
This method corresponds to the original {@code _getClassLoader()} method and returns
{@link Module} based on original class. This module is then used when defining proxy classes.

Most likely we want to return a {@link Module} into which the originalClass belongs but in case such a module
doesn't know Weld dependencies, we need to return different module, one that was used by the deployment.