public static class Implementation.Context.Default extends Implementation.Context.ExtractableView.AbstractBase
Implementation.Context.ExtractableView
which serves as its own MethodAccessorFactory
.Modifier and Type | Class and Description |
---|---|
protected static class |
Implementation.Context.Default.AbstractPropertyAccessorMethod
A base implementation of a method that accesses a property of an instrumented type.
|
protected static class |
Implementation.Context.Default.AccessorMethod
A description of an accessor method to access another method from outside the instrumented type.
|
protected static class |
Implementation.Context.Default.AccessorMethodDelegation
An implementation of a
TypeWriter.MethodPool.Record for implementing
an accessor method. |
protected static class |
Implementation.Context.Default.CacheValueField
A description of a field that stores a cached value.
|
protected static class |
Implementation.Context.Default.DelegationRecord
An abstract method pool entry that delegates the implementation of a method to itself.
|
static class |
Implementation.Context.Default.Factory
A factory for creating a
Implementation.Context.Default
that uses a random suffix for accessors. |
protected static class |
Implementation.Context.Default.FieldCacheEntry
A field cache entry for uniquely identifying a cached field.
|
protected static class |
Implementation.Context.Default.FieldGetter
A description of a field getter method.
|
protected static class |
Implementation.Context.Default.FieldGetterDelegation
An implementation for a field getter.
|
protected static class |
Implementation.Context.Default.FieldSetter
A description of a field setter method.
|
protected static class |
Implementation.Context.Default.FieldSetterDelegation
An implementation for a field setter.
|
Implementation.Context.ExtractableView.AbstractBase
Implementation.Context.Default, Implementation.Context.Disabled, Implementation.Context.ExtractableView, Implementation.Context.FrameGeneration
MethodAccessorFactory.AccessType, MethodAccessorFactory.Illegal
Modifier and Type | Field and Description |
---|---|
static String |
ACCESSOR_METHOD_SUFFIX
The name suffix to be appended to an accessor method.
|
static String |
FIELD_CACHE_PREFIX
The name prefix to be prepended to a field storing a cached value.
|
classFileVersion, frameGeneration, instrumentedType
Modifier | Constructor and Description |
---|---|
protected |
Default(TypeDescription instrumentedType,
ClassFileVersion classFileVersion,
AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy,
TypeInitializer typeInitializer,
ClassFileVersion auxiliaryClassFileVersion,
Implementation.Context.FrameGeneration frameGeneration,
String suffix)
Creates a new default implementation context.
|
Modifier and Type | Method and Description |
---|---|
FieldDescription.InDefinedShape |
cache(StackManipulation fieldValue,
TypeDescription fieldType)
Caches a single value by storing it in form of a
private , final and static field. |
void |
drain(TypeInitializer.Drain drain,
ClassVisitor classVisitor,
AnnotationValueFilter.Factory annotationValueFilterFactory)
Writes any information that was registered with an
Implementation.Context
to the provided class visitor. |
List<DynamicType> |
getAuxiliaryTypes()
Returns any
AuxiliaryType that was registered
with this Implementation.Context . |
boolean |
isEnabled()
Returns
true if this implementation context permits the registration of any implicit type initializers. |
TypeDescription |
register(AuxiliaryType auxiliaryType)
Registers an auxiliary type as required for the current implementation.
|
MethodDescription.InDefinedShape |
registerAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation,
MethodAccessorFactory.AccessType accessType)
Registers an accessor method for a
Implementation.SpecialMethodInvocation which cannot itself be
triggered invoked directly from outside a type. |
MethodDescription.InDefinedShape |
registerGetterFor(FieldDescription fieldDescription,
MethodAccessorFactory.AccessType accessType)
Registers a getter for the given
FieldDescription which might
itself not be accessible from outside the class. |
MethodDescription.InDefinedShape |
registerSetterFor(FieldDescription fieldDescription,
MethodAccessorFactory.AccessType accessType)
Registers a setter for the given
FieldDescription which might
itself not be accessible from outside the class. |
getClassFileVersion, getFrameGeneration, getInstrumentedType
public static final String ACCESSOR_METHOD_SUFFIX
public static final String FIELD_CACHE_PREFIX
protected Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, TypeInitializer typeInitializer, ClassFileVersion auxiliaryClassFileVersion, Implementation.Context.FrameGeneration frameGeneration, String suffix)
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.frameGeneration
- Determines the frame generation to be applied.suffix
- The suffix to append to the names of accessor methods.public boolean isEnabled()
true
if this implementation context permits the registration of any implicit type initializers.true
if this implementation context permits the registration of any implicit type initializers.public MethodDescription.InDefinedShape registerAccessorFor(Implementation.SpecialMethodInvocation specialMethodInvocation, MethodAccessorFactory.AccessType accessType)
Implementation.SpecialMethodInvocation
which 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.specialMethodInvocation
- The special method invocation.accessType
- The required access type.public MethodDescription.InDefinedShape registerGetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
FieldDescription
which 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 is static
, this accessor method is also static
.fieldDescription
- The field which is to be accessed.accessType
- The required access type.public MethodDescription.InDefinedShape registerSetterFor(FieldDescription fieldDescription, MethodAccessorFactory.AccessType accessType)
FieldDescription
which might
itself not be accessible from outside the class. The returned setter method defines the field type as
its only argument type, returns void
and is of package-private visibility, similarly to the Java
compiler's accessor methods. If the field is static
, this accessor method is also static
.fieldDescription
- The field which is to be accessed.accessType
- The required access type.public TypeDescription register(AuxiliaryType auxiliaryType)
auxiliaryType
- The auxiliary type that is required for the current implementation.public List<DynamicType> getAuxiliaryTypes()
AuxiliaryType
that was registered
with this Implementation.Context
.public FieldDescription.InDefinedShape cache(StackManipulation fieldValue, TypeDescription fieldType)
private
, final
and static
field.
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.fieldValue
- A stack manipulation for creating the value that is to be cached in a static
field.
After executing the stack manipulation, exactly one value must be put onto the operand
stack which is assignable to the given fieldType
.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.public void drain(TypeInitializer.Drain drain, ClassVisitor classVisitor, AnnotationValueFilter.Factory annotationValueFilterFactory)
Implementation.Context
to 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.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.Copyright © 2014–2024. All rights reserved.