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
ByteBuddyState.ProxyDefinitionHelpers
Shared proxy definition helpers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBuddyState.ProxyDefinitionHelpers
getProxyDefinitionHelpers()
Returns the proxy definition helpers to reuse when defining proxies.Class<?>
load(Class<?> referenceClass, Function<net.bytebuddy.ByteBuddy,net.bytebuddy.dynamic.DynamicType.Builder<?>> makeClassFunction)
Load a class generated by ByteBuddy.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 theProxyFactory
.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.
-
-
-
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 theProxyFactory
.- 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 TypePoolclassName
- 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)
-
-