Class ByteBuddyState

java.lang.Object
org.hibernate.bytecode.internal.bytebuddy.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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Shared proxy definition helpers.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Returns the proxy definition helpers to reuse when defining proxies.
    load(Class<?> referenceClass, String className, BiFunction<net.bytebuddy.ByteBuddy,net.bytebuddy.NamingStrategy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeClassFunction)
    Load a class generated by ByteBuddy.
    load(Class<?> referenceClass, Function<net.bytebuddy.ByteBuddy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeClassFunction)
    Load a class generated by ByteBuddy.
    loadProxy(Class<?> referenceClass, String proxyClassName, BiFunction<net.bytebuddy.ByteBuddy,net.bytebuddy.NamingStrategy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
    Load a proxy as generated by the ProxyFactory.
    loadProxy(Class<?> referenceClass, net.bytebuddy.TypeCache.SimpleKey cacheKey, Function<net.bytebuddy.ByteBuddy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
    Deprecated, for removal: This API element is subject to removal in a future version.
    net.bytebuddy.dynamic.DynamicType.Unloaded<?>
    make(Function<net.bytebuddy.ByteBuddy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
     
    net.bytebuddy.dynamic.DynamicType.Unloaded<?>
    make(net.bytebuddy.pool.TypePool typePool, Function<net.bytebuddy.ByteBuddy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ByteBuddyState

      public ByteBuddyState()
  • Method Details

    • loadProxy

      @Deprecated(forRemoval=true, since="6.6") public Class<?> loadProxy(Class<?> referenceClass, net.bytebuddy.TypeCache.SimpleKey cacheKey, Function<net.bytebuddy.ByteBuddy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeProxyFunction)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
    • loadProxy

      public Class<?> loadProxy(Class<?> referenceClass, String proxyClassName, BiFunction<net.bytebuddy.ByteBuddy,net.bytebuddy.NamingStrategy,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.
      proxyClassName - The proxy class name.
      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.
    • load

      public Class<?> load(Class<?> referenceClass, String className, BiFunction<net.bytebuddy.ByteBuddy,net.bytebuddy.NamingStrategy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeClassFunction)
      Load a class generated by ByteBuddy.
      Parameters:
      referenceClass - The main class for which to create a class - might be an interface.
      className - The name under which the class shall be created.
      makeClassFunction - A function building the class.
      Returns:
      The loaded generated class.
    • 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)
    • getEnhancerConstants

      public EnhancerImplConstants getEnhancerConstants()