class ProxyFactoryTransformer {

    /**
     * Patch AbstractProxyFactory class.
     *   - add factory registration into constructor
     *   - changes call classLoader.loadClass(...) in getProxyClass() to ProxyClassLoadingDelegate.loadClass(classLoader, ...)
     *   - changes call ClassFileUtils.toClass() in createProxyClass() to ProxyClassLoadingDelegate.loadClass(...)
     *
     * @param ctClass the ProxyFactory class
     * @param classPool the class pool
     * @throws NotFoundException the not found exception
     * @throws CannotCompileException the cannot compile exception
     */
    @OnClassLoadEvent(classNameRegexp = "org.apache.webbeans.proxy.AbstractProxyFactory")
    public static void patchProxyFactory(CtClass ctClass, ClassPool classPool) throws NotFoundException, CannotCompileException {<FILL_FUNCTION_BODY>}

}

        if (HaCdiCommons.isJakarta(classPool)) {
            return;
        }
        CtMethod getProxyClassMethod = ctClass.getDeclaredMethod("getUnusedProxyClassName");
        getProxyClassMethod.instrument(
                new ExprEditor() {
                    public void edit(MethodCall m) throws CannotCompileException {
                        if (m.getClassName().equals(Class.class.getName()) && m.getMethodName().equals("forName"))
                            m.replace("{ $_ = org.hotswap.agent.plugin.owb.command.ProxyClassLoadingDelegate.forName($$); }");
                    }
                });

        CtMethod createProxyClassMethod = ctClass.getDeclaredMethod("createProxyClass", new CtClass[] {
                classPool.get(ClassLoader.class.getName()),
                classPool.get(String.class.getName()),
                classPool.get(Class.class.getName()),
                classPool.get(Method.class.getName() + "[]"),
                classPool.get(Method.class.getName() + "[]"),
                classPool.get(Constructor.class.getName())
            }
        );

        createProxyClassMethod.instrument(
                new ExprEditor() {
                    public void edit(MethodCall m) throws CannotCompileException {
                        if (m.getMethodName().equals("defineAndLoadClass"))
                            if ("org.apache.webbeans.proxy.Unsafe".equals(m.getClassName())) {
                                // OWB >= 2.0.8
                                m.replace("{ $_ = org.hotswap.agent.plugin.owb.command.ProxyClassLoadingDelegate.defineAndLoadClassWithUnsafe(this.unsafe, $$); }");
                            } else {
                                // OWB < 2.0.8
                                m.replace("{ $_ = org.hotswap.agent.plugin.owb.command.ProxyClassLoadingDelegate.defineAndLoadClass(this, $$); }");
                            }
                    }
                });
    
<no_super_class>