Package net.bytebuddy.implementation
Class Implementation.Context.Default
- java.lang.Object
-
- net.bytebuddy.implementation.Implementation.Context.ExtractableView.AbstractBase
-
- net.bytebuddy.implementation.Implementation.Context.Default
-
- All Implemented Interfaces:
Implementation.Context,Implementation.Context.ExtractableView,MethodAccessorFactory
- Enclosing interface:
- Implementation.Context
public static class Implementation.Context.Default extends Implementation.Context.ExtractableView.AbstractBase
A default implementation of anImplementation.Context.ExtractableViewwhich serves as its ownMethodAccessorFactory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classImplementation.Context.Default.AbstractPropertyAccessorMethodA base implementation of a method that accesses a property of an instrumented type.protected static classImplementation.Context.Default.AccessorMethodA description of an accessor method to access another method from outside the instrumented type.protected static classImplementation.Context.Default.AccessorMethodDelegationAn implementation of aTypeWriter.MethodPool.Recordfor implementing an accessor method.protected static classImplementation.Context.Default.CacheValueFieldA description of a field that stores a cached value.protected static classImplementation.Context.Default.DelegationRecordAn abstract method pool entry that delegates the implementation of a method to itself.static classImplementation.Context.Default.FactoryA factory for creating aImplementation.Context.Default.protected static classImplementation.Context.Default.FieldCacheEntryA field cache entry for uniquely identifying a cached field.protected static classImplementation.Context.Default.FieldGetterA description of a field getter method.protected static classImplementation.Context.Default.FieldGetterDelegationAn implementation for a field getter.protected static classImplementation.Context.Default.FieldSetterA description of a field setter method.protected static classImplementation.Context.Default.FieldSetterDelegationAn implementation for a field setter.-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation.Context
Implementation.Context.Default, Implementation.Context.Disabled, Implementation.Context.ExtractableView
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation.Context.ExtractableView
Implementation.Context.ExtractableView.AbstractBase
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.MethodAccessorFactory
MethodAccessorFactory.AccessType, MethodAccessorFactory.Illegal
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACCESSOR_METHOD_SUFFIXThe name suffix to be appended to an accessor method.static java.lang.StringFIELD_CACHE_PREFIXThe name prefix to be prepended to a field storing a cached value.-
Fields inherited from class net.bytebuddy.implementation.Implementation.Context.ExtractableView.AbstractBase
classFileVersion, instrumentedType
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefault(TypeDescription instrumentedType, ClassFileVersion classFileVersion, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, TypeInitializer typeInitializer, ClassFileVersion auxiliaryClassFileVersion)Creates a new default implementation context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldDescription.InDefinedShapecache(StackManipulation fieldValue, TypeDescription fieldType)Caches a single value by storing it in form of aprivate,finalandstaticfield.voiddrain(TypeInitializer.Drain drain, org.objectweb.asm.ClassVisitor classVisitor, AnnotationValueFilter.Factory annotationValueFilterFactory)Writes any information that was registered with anImplementation.Contextto the provided class visitor.java.util.List<DynamicType>getAuxiliaryTypes()Returns anyAuxiliaryTypethat was registered with thisImplementation.Context.booleanisEnabled()Returnstrueif this implementation context permits the registration of any implicit type initializers.TypeDescriptionregister(AuxiliaryType auxiliaryType)Registers an auxiliary type as required for the current implementation.MethodDescription.InDefinedShaperegisterAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation, MethodAccessorFactory.AccessType accessType)Registers an accessor method for aImplementation.SpecialMethodInvocationwhich cannot itself be triggered invoked directly from outside a type.MethodDescription.InDefinedShaperegisterGetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)Registers a getter for the givenFieldDescriptionwhich might itself not be accessible from outside the class.MethodDescription.InDefinedShaperegisterSetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)Registers a setter for the givenFieldDescriptionwhich might itself not be accessible from outside the class.-
Methods inherited from class net.bytebuddy.implementation.Implementation.Context.ExtractableView.AbstractBase
getClassFileVersion, getInstrumentedType
-
-
-
-
Field Detail
-
ACCESSOR_METHOD_SUFFIX
public static final java.lang.String ACCESSOR_METHOD_SUFFIX
The name suffix to be appended to an accessor method.- See Also:
- Constant Field Values
-
FIELD_CACHE_PREFIX
public static final java.lang.String FIELD_CACHE_PREFIX
The name prefix to be prepended to a field storing a cached value.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Default
protected Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, TypeInitializer typeInitializer, ClassFileVersion auxiliaryClassFileVersion)
Creates a new default implementation context.- Parameters:
instrumentedType- The description of the type that is currently subject of creation.classFileVersion- The class file version of the created class.auxiliaryTypeNamingStrategy- The naming strategy for naming an auxiliary type.typeInitializer- The type initializer of the created instrumented type.auxiliaryClassFileVersion- The class file version to use for auxiliary classes.
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
Description copied from interface:Implementation.Context.ExtractableViewReturnstrueif this implementation context permits the registration of any implicit type initializers.- Returns:
trueif this implementation context permits the registration of any implicit type initializers.
-
registerAccessorFor
public MethodDescription.InDefinedShape registerAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation, MethodAccessorFactory.AccessType accessType)
Description copied from interface:MethodAccessorFactoryRegisters an accessor method for aImplementation.SpecialMethodInvocationwhich cannot itself be triggered invoked directly from outside a type. The method is registered on the instrumented type with package-private visibility, similarly to a Java compiler's accessor methods.- Parameters:
specialMethodInvocation- The special method invocation.accessType- The required access type.- Returns:
- The accessor method for invoking the special method invocation.
-
registerGetterFor
public MethodDescription.InDefinedShape registerGetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
Description copied from interface:MethodAccessorFactoryRegisters a getter for the givenFieldDescriptionwhich might itself not be accessible from outside the class. The returned getter method defines the field type as its return type, does not take any arguments and is of package-private visibility, similarly to the Java compiler's accessor methods. If the field isstatic, this accessor method is alsostatic.- Parameters:
fieldDescription- The field which is to be accessed.accessType- The required access type.- Returns:
- A getter method for the given field.
-
registerSetterFor
public MethodDescription.InDefinedShape registerSetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
Description copied from interface:MethodAccessorFactoryRegisters a setter for the givenFieldDescriptionwhich might itself not be accessible from outside the class. The returned setter method defines the field type as its only argument type, returnsvoidand is of package-private visibility, similarly to the Java compiler's accessor methods. If the field isstatic, this accessor method is alsostatic.- Parameters:
fieldDescription- The field which is to be accessed.accessType- The required access type.- Returns:
- A setter method for the given field.
-
register
public TypeDescription register(AuxiliaryType auxiliaryType)
Description copied from interface:Implementation.ContextRegisters an auxiliary type as required for the current implementation. Registering a type will cause the creation of this type even if this type is not effectively used for the current implementation.- Parameters:
auxiliaryType- The auxiliary type that is required for the current implementation.- Returns:
- A description of the registered auxiliary type.
-
getAuxiliaryTypes
public java.util.List<DynamicType> getAuxiliaryTypes()
Description copied from interface:Implementation.Context.ExtractableViewReturns anyAuxiliaryTypethat was registered with thisImplementation.Context.- Returns:
- A list of all manifested registered auxiliary types.
-
cache
public FieldDescription.InDefinedShape cache(StackManipulation fieldValue, TypeDescription fieldType)
Description copied from interface:Implementation.ContextCaches a single value by storing it in form of aprivate,finalandstaticfield. By caching values, expensive instance creations can be avoided and object identity can be preserved. The field is initiated in a generated class's static initializer.- Parameters:
fieldValue- A stack manipulation for creating the value that is to be cached in astaticfield. After executing the stack manipulation, exactly one value must be put onto the operand stack which is assignable to the givenfieldType.fieldType- The type of the field for storing the cached value. This field's type determines the value that is put onto the operand stack by this method's returned stack manipulation.- Returns:
- A description of a field that was defined on the instrumented type which contains the given value.
-
drain
public void drain(TypeInitializer.Drain drain, org.objectweb.asm.ClassVisitor classVisitor, AnnotationValueFilter.Factory annotationValueFilterFactory)
Description copied from interface:Implementation.Context.ExtractableViewWrites any information that was registered with anImplementation.Contextto the provided class visitor. This contains any fields for value caching, any accessor method and it writes the type initializer. The type initializer must therefore never be written manually.- Parameters:
drain- The drain to write the type initializer to.classVisitor- The class visitor to which the extractable view is to be written.annotationValueFilterFactory- The annotation value filter factory to apply when writing annotation.
-
-