Class ByteBuddyState


  • public final class ByteBuddyState
    extends Object
    A utility to hold all ByteBuddy related state, as in the current version of Hibernate the Bytecode Provider state is held in a static field, yet ByteBuddy is able to benefit from some caching and general state reuse.
    • Constructor Detail

      • ByteBuddyState

        public ByteBuddyState()
    • Method Detail

      • loadProxy

        public Class<?> loadProxy​(Class<?> referenceClass,
                                  net.bytebuddy.TypeCache.SimpleKey cacheKey,
                                  Function<net.bytebuddy.ByteBuddy,​net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
        Load a proxy as generated by the ProxyFactory.
        Parameters:
        referenceClass - The main class to proxy - might be an interface.
        cacheKey - The cache key.
        makeProxyFunction - A function building the proxy.
        Returns:
        The loaded proxy class.
      • load

        public Class<?> load​(Class<?> referenceClass,
                             Function<net.bytebuddy.ByteBuddy,​net.bytebuddy.dynamic.DynamicType.Builder<?>> makeClassFunction)
        Load a class generated by ByteBuddy.
        Parameters:
        referenceClass - The main class to proxy - might be an interface.
        makeClassFunction - A function building the class.
        Returns:
        The loaded generated class.
      • rewrite

        public byte[] rewrite​(net.bytebuddy.pool.TypePool typePool,
                              String className,
                              Function<net.bytebuddy.ByteBuddy,​net.bytebuddy.dynamic.DynamicType.Builder<?>> rewriteClassFunction)
        Rewrite a class, used by the enhancer.

        WARNING: Returns null if rewriteClassFunction returns a null builder. Do not use if you expect the original content.

        Parameters:
        typePool - the ByteBuddy TypePool
        className - The original class name.
        rewriteClassFunction - The function used to rewrite the class.
        Returns:
        The rewritten content of the class or null if rewriteClassFunction returns a null builder.
      • getProxyDefinitionHelpers

        public ByteBuddyState.ProxyDefinitionHelpers getProxyDefinitionHelpers()
        Returns the proxy definition helpers to reuse when defining proxies.

        These elements are shared as they are immutable.

        Returns:
        The proxy definition helpers.
      • make

        public net.bytebuddy.dynamic.DynamicType.Unloaded<?> make​(Function<net.bytebuddy.ByteBuddy,​net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
      • make

        public net.bytebuddy.dynamic.DynamicType.Unloaded<?> make​(net.bytebuddy.pool.TypePool typePool,
                                                                  Function<net.bytebuddy.ByteBuddy,​net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)