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

public Class EnhancerImpl

extends Object
implements Enhancer
Class Inheritance
All Implemented Interfaces
org.hibernate.bytecode.enhance.spi.Enhancer
Static Imports
net.bytebuddy.matcher.ElementMatchers.isDefaultFinalizer

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
EnhancerImpl.EnhancementStatus

Attempt to keep track of which interfaces are being applied, so to attempt dodging the performance implications of for https://bugs.openjdk.org/browse/JDK-8180450 We're optimising for the case in which entities are fully enhanced.

private static class

Field Summary

Modifier and TypeField and Description
private final Advice
private final ClassFileLocator
adviceLocator

Extract the following constants so that enhancement on large projects can be done efficiently: otherwise each instance use will trigger a resource load on the ClassLoader tree, triggering allocation of several streams to unzip each JAR file each time.

private final ByteBuddyState
private final EnhancerImpl.EnhancerClassFileLocator
protected final ByteBuddyEnhancementContext
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private final Implementation
private static final CoreMessageLogger
private static final AnnotationDescription
private final TypePool

Constructor Summary

AccessConstructor and Description
public
EnhancerImpl(final EnhancementContext
Describes the context in which enhancement will occur so as to give access to contextual/environmental information.
enhancementContext
,
final ByteBuddyState
refers to the ByteBuddy instance to use
byteBuddyState
)

Constructs the Enhancer, using the given context.

Method Summary

Modifier and TypeMethod and Description
private static DynamicType.Builder<?>
addFieldWithGetterAndSetter(DynamicType.Builder<?> builder, Class<?> type, String fieldName, String getterName, String setterName)

private DynamicType.Builder<?>
private boolean
private TypePool
buildTypePool(final ClassFileLocator classFileLocator)

pack-priv static String
private List<EnhancerImpl.AnnotatedFieldDescription>
private Collection<EnhancerImpl.AnnotatedFieldDescription>
private PersistentAttributeTransformer
private DynamicType.Builder<?>
doEnhance(DynamicType.Builder<?> builder, TypeDescription managedCtClass)

public byte[]

Returns:

The enhanced bytecode. Could be the same as the original bytecode if the original was already enhanced or we could not enhance it for some reason.
enhance
(String
The name of the class whose bytecode is being enhanced.
className
,
byte[]
The class's original (pre-enhancement) byte code
originalBytes
)

Implements org.hibernate.bytecode.enhance.spi.Enhancer.enhance.

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

Field Detail

adviceInitializeLazyAttributeLoadingInterceptorback to summary
private final Advice adviceInitializeLazyAttributeLoadingInterceptor
adviceLocatorback to summary
private final ClassFileLocator adviceLocator

Extract the following constants so that enhancement on large projects can be done efficiently: otherwise each instance use will trigger a resource load on the ClassLoader tree, triggering allocation of several streams to unzip each JAR file each time.

byteBuddyStateback to summary
private final ByteBuddyState byteBuddyState
classFileLocatorback to summary
private final EnhancerImpl.EnhancerClassFileLocator classFileLocator
enhancementContextback to summary
protected final ByteBuddyEnhancementContext enhancementContext
implementationAreFieldsDirtyback to summary
private final Implementation implementationAreFieldsDirty
implementationAreFieldsDirtyWithoutCollectionsback to summary
private final Implementation implementationAreFieldsDirtyWithoutCollections
implementationClearDirtyAttributesback to summary
private final Implementation implementationClearDirtyAttributes
implementationClearDirtyAttributesWithoutCollectionsback to summary
private final Implementation implementationClearDirtyAttributesWithoutCollections
implementationClearOwnerback to summary
private final Implementation implementationClearOwner
implementationGetCollectionTrackerWithoutCollectionsback to summary
private final Implementation implementationGetCollectionTrackerWithoutCollections
implementationGetDirtyAttributesback to summary
private final Implementation implementationGetDirtyAttributes
implementationGetDirtyAttributesWithoutCollectionsback to summary
private final Implementation implementationGetDirtyAttributesWithoutCollections
implementationSetOwnerback to summary
private final Implementation implementationSetOwner
implementationSuspendDirtyTrackingback to summary
private final Implementation implementationSuspendDirtyTracking
implementationTrackChangeback to summary
private final Implementation implementationTrackChange
logback to summary
private static final CoreMessageLogger log
TRANSIENT_ANNOTATIONback to summary
private static final AnnotationDescription TRANSIENT_ANNOTATION
typePoolback to summary
private final TypePool typePool

Constructor Detail

EnhancerImplback to summary
public EnhancerImpl(final EnhancementContext enhancementContext, final ByteBuddyState byteBuddyState)

Constructs the Enhancer, using the given context.

Parameters
enhancementContext:EnhancementContext

Describes the context in which enhancement will occur so as to give access to contextual/environmental information.

byteBuddyState:ByteBuddyState

refers to the ByteBuddy instance to use

Method Detail

addFieldWithGetterAndSetterback to summary
private static DynamicType.Builder<?> addFieldWithGetterAndSetter(DynamicType.Builder<?> builder, Class<?> type, String fieldName, String getterName, String setterName)
addInterceptorHandlingback to summary
private DynamicType.Builder<?> addInterceptorHandling(DynamicType.Builder<?> builder, TypeDescription managedCtClass, EnhancerImpl.EnhancementStatus es)
alreadyEnhancedback to summary
private boolean alreadyEnhanced(TypeDescription managedCtClass)
buildTypePoolback to summary
private TypePool buildTypePool(final ClassFileLocator classFileLocator)
capitalizeback to summary
pack-priv static String capitalize(String value)
collectCollectionFieldsback to summary
private List<EnhancerImpl.AnnotatedFieldDescription> collectCollectionFields(TypeDescription managedCtClass)
collectInheritCollectionFieldsback to summary
private Collection<EnhancerImpl.AnnotatedFieldDescription> collectInheritCollectionFields(TypeDefinition managedCtClass)
createTransformerback to summary
private PersistentAttributeTransformer createTransformer(TypeDescription typeDescription)
doEnhanceback to summary
private DynamicType.Builder<?> doEnhance(DynamicType.Builder<?> builder, TypeDescription managedCtClass)
enhanceback to summary
public byte[] enhance(String className, byte[] originalBytes) throws EnhancementException

Implements org.hibernate.bytecode.enhance.spi.Enhancer.enhance.

Performs the enhancement.

Parameters
className:String

The name of the class whose bytecode is being enhanced.

originalBytes:byte[]

The class's original (pre-enhancement) byte code

Returns:byte[]

The enhanced bytecode. Could be the same as the original bytecode if the original was already enhanced or we could not enhance it for some reason.

Annotations
@Override
Exceptions
EnhancementException:
Indicates a problem performing the enhancement
org.hibernate.bytecode.enhance.internal.bytebuddy back to summary

pack-priv Class EnhancerImpl.AnnotatedFieldDescription

extends Object
implements UnloadedField
Class Inheritance
  • java.lang.Object
  • org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.AnnotatedFieldDescription
All Implemented Interfaces
org.hibernate.bytecode.enhance.spi.UnloadedField

Field Summary

Modifier and TypeField and Description
private AnnotationList
private final ByteBuddyEnhancementContext
private final FieldDescription
private Optional<MethodDescription>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv FieldDescription.InDefinedShape
private AnnotationList
pack-priv <T extends Annotation> AnnotationDescription.Loadable<T>
getAnnotation(Class<T> annotationType)

private AnnotationList
pack-priv TypeDefinition
pack-priv String
pack-priv FieldDescription
pack-priv Optional<MethodDescription>
pack-priv String
pack-priv TypeDescription.Generic
public boolean
pack-priv boolean
isVisibleTo(TypeDescription typeDescription)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

annotationsback to summary
private AnnotationList annotations
contextback to summary
private final ByteBuddyEnhancementContext context
fieldDescriptionback to summary
private final FieldDescription fieldDescription
getterback to summary
private Optional<MethodDescription> getter

Constructor Detail

AnnotatedFieldDescriptionback to summary
pack-priv AnnotatedFieldDescription(ByteBuddyEnhancementContext context, FieldDescription fieldDescription)

Method Detail

asDefinedback to summary
pack-priv FieldDescription.InDefinedShape asDefined()
doGetAnnotationsback to summary
private AnnotationList doGetAnnotations()
getAnnotationback to summary
pack-priv <T extends Annotation> AnnotationDescription.Loadable<T> getAnnotation(Class<T> annotationType)
getAnnotationsback to summary
private AnnotationList getAnnotations()
getDeclaringTypeback to summary
pack-priv TypeDefinition getDeclaringType()
getDescriptorback to summary
pack-priv String getDescriptor()
getFieldDescriptionback to summary
pack-priv FieldDescription getFieldDescription()
getGetterback to summary
pack-priv Optional<MethodDescription> getGetter()
getNameback to summary
pack-priv String getName()
getTypeback to summary
pack-priv TypeDescription.Generic getType()
hasAnnotationback to summary
public boolean hasAnnotation(Class<? extends Annotation> annotationType)

Implements org.hibernate.bytecode.enhance.spi.UnloadedField.hasAnnotation.

Annotations
@Override
isVisibleToback to summary
pack-priv boolean isVisibleTo(TypeDescription typeDescription)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

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

pack-priv final Class EnhancerImpl.EnhancementStatus

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.bytecode.enhance.internal.bytebuddy.EnhancerImpl.EnhancementStatus

Attempt to keep track of which interfaces are being applied, so to attempt dodging the performance implications of for https://bugs.openjdk.org/browse/JDK-8180450 We're optimising for the case in which entities are fully enhanced.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private boolean
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

Field Detail

appliedback to summary
private boolean applied
managedEntityback to summary
private boolean managedEntity
persistentAttributeInterceptableback to summary
private boolean persistentAttributeInterceptable
selfDirtynessTrackerback to summary
private boolean selfDirtynessTracker
typeNameback to summary
private final String typeName

Constructor Detail

EnhancementStatusback to summary
public EnhancementStatus(String typeName)

Method Detail

applySuperInterfaceOptimisationsback to summary
public DynamicType.Builder<?> applySuperInterfaceOptimisations(DynamicType.Builder<?> builder)
enabledInterfaceManagedEntityback to summary
public void enabledInterfaceManagedEntity()
enabledInterfacePersistentAttributeInterceptableback to summary
public void enabledInterfacePersistentAttributeInterceptable()
enabledInterfaceSelfDirtinessTrackerback to summary
public void enabledInterfaceSelfDirtinessTracker()
org.hibernate.bytecode.enhance.internal.bytebuddy back to summary

private Class EnhancerImpl.EnhancerClassFileLocator

extends ForClassLoader
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String
private ClassFileLocator.Resolution

Constructor Summary

AccessConstructor and Description
protected
EnhancerClassFileLocator(ClassLoader
The class loader to query which must not be the bootstrap class loader, i.e. null.
classLoader
)

Creates a new class file locator for the given class loader.

Method Summary

Modifier and TypeMethod and Description
public ClassFileLocator.Resolution
locate(String
The name of the type to locate a class file representation for.
className
)

Overrides net.bytebuddy.dynamic.ClassFileLocator.ForClassLoader.locate.

Implements net.bytebuddy.dynamic.ClassFileLocator.locate.

Locates the class file for a given type and returns the binary data of the class file.
pack-priv void
setClassNameAndBytes(String className, byte[] bytes)

Inherited from net.bytebuddy.dynamic.ClassFileLocator.ForClassLoader:
closelocateofofBootLoaderofPlatformLoaderofSystemLoaderreadreadreadreadToNamesreadToNames

Field Detail

classNameback to summary
private String className
resolutionback to summary
private ClassFileLocator.Resolution resolution

Constructor Detail

EnhancerClassFileLocatorback to summary
protected EnhancerClassFileLocator(ClassLoader classLoader)

Creates a new class file locator for the given class loader.

Parameters
classLoader:ClassLoader

The class loader to query which must not be the bootstrap class loader, i.e. null.

Method Detail

locateback to summary
public ClassFileLocator.Resolution locate(String className) throws IOException

Overrides net.bytebuddy.dynamic.ClassFileLocator.ForClassLoader.locate.

Implements net.bytebuddy.dynamic.ClassFileLocator.locate.

Doc from net.bytebuddy.dynamic.ClassFileLocator.ForClassLoader.locate.

Locates the class file for a given type and returns the binary data of the class file.

Parameters
className:String

Doc from net.bytebuddy.dynamic.ClassFileLocator.locate.

The name of the type to locate a class file representation for.

Returns:ClassFileLocator.Resolution

Doc from net.bytebuddy.dynamic.ClassFileLocator.locate.

Any binary representation of the type which might be illegal.

Annotations
@Override
Exceptions
IOException:

Doc from net.bytebuddy.dynamic.ClassFileLocator.locate.

If reading a class file causes an error.

setClassNameAndBytesback to summary
pack-priv void setClassNameAndBytes(String className, byte[] bytes)