Top Description Inners Fields Constructors Methods
org.hibernate.bytecode.internal.bytebuddy

public final Class ByteBuddyState

extends Object
Class Inheritance
Static Imports
net.bytebuddy.matcher.ElementMatchers.isDeclaredBy, .ElementMatchers.isFinalizer, .ElementMatchers.isSynthetic, .ElementMatchers.isVirtual, .ElementMatchers.nameStartsWith, .ElementMatchers.named, .ElementMatchers.not, .ElementMatchers.returns, .ElementMatchers.takesNoArguments, org.hibernate.internal.CoreLogging.messageLogger

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 and Inner Type Summary

Modifier and TypeClass and Description
private static interface
private static class
public static class
ByteBuddyState.ProxyDefinitionHelpers

Shared proxy definition helpers.

private static class
private static class

Field Summary

Modifier and TypeField and Description
private final TypeCache<TypeCache.SimpleKey>
private final ByteBuddy
private final ByteBuddyState.ClassRewriter
private static final boolean
private static final CoreMessageLogger
private static final MethodHandles.Lookup
private final TypeCache<TypeCache.SimpleKey>
proxyCache

It will be easier to maintain the cache and its state when it will no longer be static in Hibernate ORM 6+.

private static final ByteBuddyState.ProxyDefinitionHelpers

Constructor Summary

AccessConstructor and Description
public
pack-priv
ByteBuddyState(ClassFileVersion classFileVersion)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
clearState()

Wipes out all known caches used by ByteBuddy.

public ByteBuddyState.ProxyDefinitionHelpers

Returns:

The proxy definition helpers.
getProxyDefinitionHelpers
()

Returns the proxy definition helpers to reuse when defining proxies.

public Class<?>

Returns:

The loaded generated class.
load
(Class<?>
The main class to proxy - might be an interface.
referenceClass
,
Function<ByteBuddy, DynamicType.Builder<?>>
A function building the class.
makeClassFunction
)

Load a class generated by ByteBuddy.

private Class<?>
load(Class<?> referenceClass, TypeCache<TypeCache.SimpleKey> cache, TypeCache.SimpleKey cacheKey, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)

pack-priv Class<?>

Returns:

The loaded proxy class.
loadBasicProxy
(Class<?>
The main class to proxy - might be an interface.
referenceClass
,
TypeCache.SimpleKey
The cache key.
cacheKey
,
Function<ByteBuddy, DynamicType.Builder<?>>
A function building the proxy.
makeProxyFunction
)

Load a proxy as generated by the BasicProxyFactory.

public Class<?>

Returns:

The loaded proxy class.
loadProxy
(Class<?>
The main class to proxy - might be an interface.
referenceClass
,
TypeCache.SimpleKey
The cache key.
cacheKey
,
Function<ByteBuddy, DynamicType.Builder<?>>
A function building the proxy.
makeProxyFunction
)

Load a proxy as generated by the ProxyFactory.

public DynamicType.Unloaded<?>
make(Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)

public DynamicType.Unloaded<?>
make(TypePool typePool, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)

private DynamicType.Unloaded<?>
make(DynamicType.Builder<?> builder)

private DynamicType.Unloaded<?>
make(TypePool typePool, DynamicType.Builder<?> builder)

private static ClassLoadingStrategy<ClassLoader>
public byte[]

Returns:

The rewritten content of the class or null if rewriteClassFunction returns a null builder.
rewrite
(TypePool
the ByteBuddy TypePool
typePool
,
String
The original class name.
className
,
Function<ByteBuddy, DynamicType.Builder<?>>
The function used to rewrite the class.
rewriteClassFunction
)

Rewrite a class, used by the enhancer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

basicProxyCacheback to summary
private final TypeCache<TypeCache.SimpleKey> basicProxyCache
byteBuddyback to summary
private final ByteBuddy byteBuddy
classRewriterback to summary
private final ByteBuddyState.ClassRewriter classRewriter
DEBUGback to summary
private static final boolean DEBUG
LOGback to summary
private static final CoreMessageLogger LOG
LOOKUPback to summary
private static final MethodHandles.Lookup LOOKUP
proxyCacheback to summary
private final TypeCache<TypeCache.SimpleKey> proxyCache

It will be easier to maintain the cache and its state when it will no longer be static in Hibernate ORM 6+. Opted for WEAK keys to avoid leaking the classloader in case the SessionFactory isn't closed. Avoiding Soft keys as they are prone to cause issues with unstable performance.

proxyDefinitionHelpersback to summary
private static final ByteBuddyState.ProxyDefinitionHelpers proxyDefinitionHelpers

Constructor Detail

ByteBuddyStateback to summary
public ByteBuddyState()
ByteBuddyStateback to summary
pack-priv ByteBuddyState(ClassFileVersion classFileVersion)

Method Detail

clearStateback to summary
pack-priv void clearState()

Wipes out all known caches used by ByteBuddy. This implies it might trigger the need to re-create some helpers if used at runtime, especially as this state might be shared by multiple SessionFactory instances, but at least ensures we cleanup anything which is no longer needed after a SessionFactory close. The assumption is that closing SessionFactories is a rare event; in this perspective the cost of re-creating the small helpers should be negligible.

getProxyDefinitionHelpersback to summary
public ByteBuddyState.ProxyDefinitionHelpers getProxyDefinitionHelpers()

Returns the proxy definition helpers to reuse when defining proxies.

These elements are shared as they are immutable.

Returns:ByteBuddyState.ProxyDefinitionHelpers

The proxy definition helpers.

loadback to summary
public Class<?> load(Class<?> referenceClass, Function<ByteBuddy, DynamicType.Builder<?>> makeClassFunction)

Load a class generated by ByteBuddy.

Parameters
referenceClass:Class<?>

The main class to proxy - might be an interface.

makeClassFunction:Function<ByteBuddy, DynamicType.Builder<?>>

A function building the class.

Returns:Class<?>

The loaded generated class.

loadback to summary
private Class<?> load(Class<?> referenceClass, TypeCache<TypeCache.SimpleKey> cache, TypeCache.SimpleKey cacheKey, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)
loadBasicProxyback to summary
pack-priv Class<?> loadBasicProxy(Class<?> referenceClass, TypeCache.SimpleKey cacheKey, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)

Load a proxy as generated by the BasicProxyFactory.

Parameters
referenceClass:Class<?>

The main class to proxy - might be an interface.

cacheKey:TypeCache.SimpleKey

The cache key.

makeProxyFunction:Function<ByteBuddy, DynamicType.Builder<?>>

A function building the proxy.

Returns:Class<?>

The loaded proxy class.

loadProxyback to summary
public Class<?> loadProxy(Class<?> referenceClass, TypeCache.SimpleKey cacheKey, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)

Load a proxy as generated by the ProxyFactory.

Parameters
referenceClass:Class<?>

The main class to proxy - might be an interface.

cacheKey:TypeCache.SimpleKey

The cache key.

makeProxyFunction:Function<ByteBuddy, DynamicType.Builder<?>>

A function building the proxy.

Returns:Class<?>

The loaded proxy class.

makeback to summary
public DynamicType.Unloaded<?> make(Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)
makeback to summary
public DynamicType.Unloaded<?> make(TypePool typePool, Function<ByteBuddy, DynamicType.Builder<?>> makeProxyFunction)
makeback to summary
private DynamicType.Unloaded<?> make(DynamicType.Builder<?> builder)
makeback to summary
private DynamicType.Unloaded<?> make(TypePool typePool, DynamicType.Builder<?> builder)
resolveClassLoadingStrategyback to summary
private static ClassLoadingStrategy<ClassLoader> resolveClassLoadingStrategy(Class<?> originalClass)
rewriteback to summary
public byte[] rewrite(TypePool typePool, String className, Function<ByteBuddy, 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:TypePool

the ByteBuddy TypePool

className:String

The original class name.

rewriteClassFunction:Function<ByteBuddy, DynamicType.Builder<?>>

The function used to rewrite the class.

Returns:byte[]

The rewritten content of the class or null if rewriteClassFunction returns a null builder.

org.hibernate.bytecode.internal.bytebuddy back to summary

private Interface ByteBuddyState.ClassRewriter

Known Direct Implementers
org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.SecurityManagerClassRewriter, org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.StandardClassRewriter

Method Summary

Modifier and TypeMethod and Description
public DynamicType.Builder<?>
public void

Method Detail

installReflectionMethodVisitorsback to summary
public DynamicType.Builder<?> installReflectionMethodVisitors(DynamicType.Builder<?> builder)
registerAuthorizedClassback to summary
public void registerAuthorizedClass(DynamicType.Unloaded<?> unloadedClass)
org.hibernate.bytecode.internal.bytebuddy back to summary

private Class ByteBuddyState.GetDeclaredMethodAction

extends Object
implements PrivilegedAction<Method>
Class Inheritance
  • java.lang.Object
  • org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.GetDeclaredMethodAction
All Implemented Interfaces
java.security.PrivilegedAction

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final String
private final Class<?>[]

Constructor Summary

AccessConstructor and Description
private
GetDeclaredMethodAction(Class<?> clazz, String methodName, Class<?>... parameterTypes)

Method Summary

Modifier and TypeMethod and Description
public Method
run()

Implements java.security.PrivilegedAction.run.

Performs the computation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<?> clazz
methodNameback to summary
private final String methodName
parameterTypesback to summary
private final Class<?>[] parameterTypes

Constructor Detail

GetDeclaredMethodActionback to summary
private GetDeclaredMethodAction(Class<?> clazz, String methodName, Class<?>... parameterTypes)

Method Detail

runback to summary
public Method run()

Implements java.security.PrivilegedAction.run.

Doc from java.security.PrivilegedAction.run.

Performs the computation. This method will be called by AccessController.doPrivileged after enabling privileges.

Returns:Method

a class-dependent value that may represent the results of the computation. Each class that implements PrivilegedAction should document what (if anything) this value represents.

Annotations
@Override
org.hibernate.bytecode.internal.bytebuddy back to summary

public Class ByteBuddyState.ProxyDefinitionHelpers

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ProxyDefinitionHelpers

Shared proxy definition helpers. They are immutable so we can safely share them.

Field Summary

Modifier and TypeField and Description
private final MethodDelegation
private final ElementMatcher<? super MethodDescription>
private final FieldAccessor.PropertyConfigurable
private final ElementMatcher<? super MethodDescription>
private final List<ElementMatcher<? super MethodDescription>>
private final ElementMatcher<? super MethodDescription>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public DynamicType.Builder<?>
public MethodDelegation
public ElementMatcher<? super MethodDescription>
public FieldAccessor.PropertyConfigurable
public ElementMatcher<? super MethodDescription>
public ElementMatcher<? super MethodDescription>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateToInterceptorDispatcherMethodDelegationback to summary
private final MethodDelegation delegateToInterceptorDispatcherMethodDelegation
groovyGetMetaClassFilterback to summary
private final ElementMatcher<? super MethodDescription> groovyGetMetaClassFilter
interceptorFieldAccessorback to summary
private final FieldAccessor.PropertyConfigurable interceptorFieldAccessor
proxyNonInterceptedMethodFilterback to summary
private final ElementMatcher<? super MethodDescription> proxyNonInterceptedMethodFilter
toFullyIgnoreback to summary
private final List<ElementMatcher<? super MethodDescription>> toFullyIgnore
virtualNotFinalizerFilterback to summary
private final ElementMatcher<? super MethodDescription> virtualNotFinalizerFilter

Constructor Detail

ProxyDefinitionHelpersback to summary
private ProxyDefinitionHelpers()

Method Detail

appendIgnoreAlsoAtEndback to summary
public DynamicType.Builder<?> appendIgnoreAlsoAtEnd(DynamicType.Builder<?> builder)
getDelegateToInterceptorDispatcherMethodDelegationback to summary
public MethodDelegation getDelegateToInterceptorDispatcherMethodDelegation()
getGroovyGetMetaClassFilterback to summary
public ElementMatcher<? super MethodDescription> getGroovyGetMetaClassFilter()
getInterceptorFieldAccessorback to summary
public FieldAccessor.PropertyConfigurable getInterceptorFieldAccessor()
getProxyNonInterceptedMethodFilterback to summary
public ElementMatcher<? super MethodDescription> getProxyNonInterceptedMethodFilter()
getVirtualNotFinalizerFilterback to summary
public ElementMatcher<? super MethodDescription> getVirtualNotFinalizerFilter()
org.hibernate.bytecode.internal.bytebuddy back to summary

private Class ByteBuddyState.SecurityManagerClassRewriter

extends Object
implements ClassRewriter
Class Inheritance
  • java.lang.Object
  • org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.SecurityManagerClassRewriter
All Implemented Interfaces
org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ClassRewriter

Field Summary

Modifier and TypeField and Description
private final AsmVisitorWrapper.ForDeclaredMethods
private final AsmVisitorWrapper.ForDeclaredMethods

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static AsmVisitorWrapper.ForDeclaredMethods
private static AsmVisitorWrapper.ForDeclaredMethods
public DynamicType.Builder<?>
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

getDeclaredMethodMemberSubstitutionback to summary
private final AsmVisitorWrapper.ForDeclaredMethods getDeclaredMethodMemberSubstitution
getMethodMemberSubstitutionback to summary
private final AsmVisitorWrapper.ForDeclaredMethods getMethodMemberSubstitution

Constructor Detail

SecurityManagerClassRewriterback to summary
private SecurityManagerClassRewriter()

Method Detail

getDeclaredMethodMemberSubstitutionback to summary
private static AsmVisitorWrapper.ForDeclaredMethods getDeclaredMethodMemberSubstitution()
getMethodMemberSubstitutionback to summary
private static AsmVisitorWrapper.ForDeclaredMethods getMethodMemberSubstitution()
installReflectionMethodVisitorsback to summary
public DynamicType.Builder<?> installReflectionMethodVisitors(DynamicType.Builder<?> builder)

Implements org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ClassRewriter.installReflectionMethodVisitors.

Annotations
@Override
registerAuthorizedClassback to summary
public void registerAuthorizedClass(DynamicType.Unloaded<?> unloadedClass)

Implements org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ClassRewriter.registerAuthorizedClass.

Annotations
@Override
org.hibernate.bytecode.internal.bytebuddy back to summary

private Class ByteBuddyState.StandardClassRewriter

extends Object
implements ClassRewriter
Class Inheritance
  • java.lang.Object
  • org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.StandardClassRewriter
All Implemented Interfaces
org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ClassRewriter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public DynamicType.Builder<?>
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StandardClassRewriterback to summary
private StandardClassRewriter()

Method Detail

installReflectionMethodVisitorsback to summary
public DynamicType.Builder<?> installReflectionMethodVisitors(DynamicType.Builder<?> builder)

Implements org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ClassRewriter.installReflectionMethodVisitors.

Annotations
@Override
registerAuthorizedClassback to summary
public void registerAuthorizedClass(DynamicType.Unloaded<?> unloadedClass)

Implements org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.ClassRewriter.registerAuthorizedClass.

Annotations
@Override