public static class Instrumentation.Context.Default extends Object implements Instrumentation.Context.ExtractableView, AuxiliaryType.MethodAccessorFactory
Instrumentation.Context.ExtractableView
which serves as its own AuxiliaryType.MethodAccessorFactory
.Modifier and Type | Class and Description |
---|---|
static interface |
Instrumentation.Context.Default.AuxiliaryTypeNamingStrategy
Representation of a naming strategy for an auxiliary type.
|
Instrumentation.Context.ExtractableView.InjectedCode
Instrumentation.Context.Default, Instrumentation.Context.ExtractableView
AuxiliaryType.MethodAccessorFactory.Illegal
FIELD_CACHE_MODIFIER
ACCESSOR_METHOD_MODIFIER
Constructor and Description |
---|
Default(TypeDescription instrumentedType,
ClassFileVersion classFileVersion)
Creates a new delegate.
|
Default(TypeDescription instrumentedType,
ClassFileVersion classFileVersion,
String accessorMethodSuffix,
String fieldCachePrefix,
Instrumentation.Context.Default.AuxiliaryTypeNamingStrategy auxiliaryTypeNamingStrategy)
Creates a new delegate.
|
Modifier and Type | Method and Description |
---|---|
FieldDescription |
cache(StackManipulation fieldValue,
TypeDescription fieldType)
Caches a single value by storing it in form of a
private , final and static field. |
void |
drain(org.objectweb.asm.ClassVisitor classVisitor,
TypeWriter.MethodPool methodPool,
Instrumentation.Context.ExtractableView.InjectedCode injectedCode)
Writes any information that was registered with an
Instrumentation.Context
to the provided class visitor. |
List<DynamicType> |
getRegisteredAuxiliaryTypes()
Returns any
AuxiliaryType that was registered
with this Instrumentation.Context . |
TypeDescription |
register(AuxiliaryType auxiliaryType)
Registers an auxiliary type as required for the current instrumentation.
|
MethodDescription |
registerAccessorFor(Instrumentation.SpecialMethodInvocation specialMethodInvocation)
Registers an accessor method for a
Instrumentation.SpecialMethodInvocation which cannot be triggered
invoked directly from outside a type. |
String |
toString() |
public Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion)
instrumentedType
- The description of the type that is currently subject of creation.classFileVersion
- The class file version of the created class.public Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion, String accessorMethodSuffix, String fieldCachePrefix, Instrumentation.Context.Default.AuxiliaryTypeNamingStrategy auxiliaryTypeNamingStrategy)
instrumentedType
- The description of the type that is currently subject of creation.classFileVersion
- The class file version of the created class.accessorMethodSuffix
- A suffix that is added to any accessor method where the method name is
prefixed by the accessed method's name.fieldCachePrefix
- A prefix that is added to any field cache.auxiliaryTypeNamingStrategy
- The naming strategy for naming an auxiliary type.public MethodDescription registerAccessorFor(Instrumentation.SpecialMethodInvocation specialMethodInvocation)
AuxiliaryType.MethodAccessorFactory
Instrumentation.SpecialMethodInvocation
which cannot 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 accessor method.registerAccessorFor
in interface AuxiliaryType.MethodAccessorFactory
specialMethodInvocation
- The special method invocation.public TypeDescription register(AuxiliaryType auxiliaryType)
Instrumentation.Context
register
in interface Instrumentation.Context
auxiliaryType
- The auxiliary type that is required for the current instrumentation.public List<DynamicType> getRegisteredAuxiliaryTypes()
Instrumentation.Context.ExtractableView
AuxiliaryType
that was registered
with this Instrumentation.Context
.getRegisteredAuxiliaryTypes
in interface Instrumentation.Context.ExtractableView
public FieldDescription cache(StackManipulation fieldValue, TypeDescription fieldType)
Instrumentation.Context
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.cache
in interface Instrumentation.Context
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(org.objectweb.asm.ClassVisitor classVisitor, TypeWriter.MethodPool methodPool, Instrumentation.Context.ExtractableView.InjectedCode injectedCode)
Instrumentation.Context.ExtractableView
Instrumentation.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
in interface Instrumentation.Context.ExtractableView
classVisitor
- The class visitor to which the extractable view is to be written.methodPool
- A method pool which is queried for any user code to add to the type initializer.injectedCode
- Potential code that is to be injected into the type initializer.Copyright © 2014. All rights reserved.