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 |
|---|---|
protected static class |
Instrumentation.Context.Default.AccessorMethodDelegation
An implementation of a
TypeWriter.MethodPool.Entry for implementing
an accessor method. |
static interface |
Instrumentation.Context.Default.AuxiliaryTypeNamingStrategy
Representation of a naming strategy for an auxiliary type.
|
protected static class |
Instrumentation.Context.Default.FieldCacheAppender
A byte code appender that writes the field cache entries to a given
MethodVisitor. |
protected static class |
Instrumentation.Context.Default.FieldCacheEntry
A field cache entry for uniquely identifying a cached field.
|
protected static class |
Instrumentation.Context.Default.FieldGetter
An implementation for a field getter.
|
protected static class |
Instrumentation.Context.Default.FieldSetter
An implementation for a field setter.
|
Instrumentation.Context.ExtractableView.InjectedCodeInstrumentation.Context.Default, Instrumentation.Context.ExtractableViewAuxiliaryType.MethodAccessorFactory.IllegalFIELD_CACHE_MODIFIERACCESSOR_METHOD_MODIFIER| Constructor and Description |
|---|
Default(TypeDescription instrumentedType,
InstrumentedType.TypeInitializer typeInitializer,
ClassFileVersion classFileVersion)
Creates a new delegate.
|
Default(TypeDescription instrumentedType,
InstrumentedType.TypeInitializer typeInitializer,
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 itself be
triggered invoked directly from outside a type. |
MethodDescription |
registerGetterFor(FieldDescription fieldDescription)
Registers a getter for the given
FieldDescription which might
itself not be accessible from outside the class. |
MethodDescription |
registerSetterFor(FieldDescription fieldDescription)
Registers a setter for the given
FieldDescription which might
itself not be accessible from outside the class. |
String |
toString() |
public Default(TypeDescription instrumentedType, InstrumentedType.TypeInitializer typeInitializer, ClassFileVersion classFileVersion)
instrumentedType - The description of the type that is currently subject of creation.typeInitializer - The type initializer of the created instrumented type.classFileVersion - The class file version of the created class.public Default(TypeDescription instrumentedType, InstrumentedType.TypeInitializer typeInitializer, ClassFileVersion classFileVersion, String accessorMethodSuffix, String fieldCachePrefix, Instrumentation.Context.Default.AuxiliaryTypeNamingStrategy auxiliaryTypeNamingStrategy)
instrumentedType - The description of the type that is currently subject of creation.typeInitializer - The type initializer of the created instrumented type.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.MethodAccessorFactoryInstrumentation.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.registerAccessorFor in interface AuxiliaryType.MethodAccessorFactoryspecialMethodInvocation - The special method invocation.public MethodDescription registerGetterFor(FieldDescription fieldDescription)
AuxiliaryType.MethodAccessorFactoryFieldDescription 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.registerGetterFor in interface AuxiliaryType.MethodAccessorFactoryfieldDescription - The field which is to be accessed.public MethodDescription registerSetterFor(FieldDescription fieldDescription)
AuxiliaryType.MethodAccessorFactoryFieldDescription 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.registerSetterFor in interface AuxiliaryType.MethodAccessorFactoryfieldDescription - The field which is to be accessed.public TypeDescription register(AuxiliaryType auxiliaryType)
Instrumentation.Contextregister in interface Instrumentation.ContextauxiliaryType - The auxiliary type that is required for the current instrumentation.public List<DynamicType> getRegisteredAuxiliaryTypes()
Instrumentation.Context.ExtractableViewAuxiliaryType that was registered
with this Instrumentation.Context.getRegisteredAuxiliaryTypes in interface Instrumentation.Context.ExtractableViewpublic FieldDescription cache(StackManipulation fieldValue, TypeDescription fieldType)
Instrumentation.Contextprivate, 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.ContextfieldValue - 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.ExtractableViewInstrumentation.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.ExtractableViewclassVisitor - 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.