Class WeldDefaultProxyServices

  • All Implemented Interfaces:
    org.jboss.weld.bootstrap.api.Service, org.jboss.weld.serialization.spi.ProxyServices

    public class WeldDefaultProxyServices
    extends Object
    implements org.jboss.weld.serialization.spi.ProxyServices
    This class is a default implementation of ProxyServices that will only be loaded if no other implementation is detected. It is only used up until JDK 11 at which point it is replaced by its alternative implementation.

    This class cracks open the class loader's defineclass method and then uses it to define new classes.

    • Constructor Detail

      • WeldDefaultProxyServices

        public WeldDefaultProxyServices()
    • Method Detail

      • makeClassLoaderMethodsAccessible

        public static void makeClassLoaderMethodsAccessible()
        This method cracks open ClassLoader#defineClass() methods by calling setAccessible().

        It is invoked during WeldStartup#startContainer() and only in case the integrator does not fully implement ProxyServices.

      • getClassLoader

        public ClassLoader getClassLoader​(Class<?> proxiedBeanType)
        Specified by:
        getClassLoader in interface org.jboss.weld.serialization.spi.ProxyServices
      • loadBeanClass

        public Class<?> loadBeanClass​(String className)
        Specified by:
        loadBeanClass in interface org.jboss.weld.serialization.spi.ProxyServices
      • defineClass

        public Class<?> defineClass​(Class<?> originalClass,
                                    String className,
                                    byte[] classBytes,
                                    int off,
                                    int len)
                             throws ClassFormatError
        Specified by:
        defineClass in interface org.jboss.weld.serialization.spi.ProxyServices
        Throws:
        ClassFormatError
      • supportsClassDefining

        public boolean supportsClassDefining()
        Specified by:
        supportsClassDefining in interface org.jboss.weld.serialization.spi.ProxyServices
      • cleanup

        public void cleanup()
        Specified by:
        cleanup in interface org.jboss.weld.bootstrap.api.Service