final
fields. In this context, it is possible that
the method is executed multiple times by different threads but at the same time, this approach avoids a volatile
field
declaration. For methods with a primitive return type, the type's default value is used to indicate that a method was not yet invoked.
For methods that return a reference type, null
is used as an indicator. If a method returns such a value, this mechanism will
not work. This plugin does not need to be closed.
Modifier and Type | Class and Description |
---|---|
protected static @interface | CachedReturnPlugin.CacheField
Indicates the field that stores the cached value. |
protected static class | CachedReturnPlugin.CacheFieldOffsetMapping
An offset mapping for the cached field. |
public static @interface | CachedReturnPlugin.Enhance
Indicates methods that should be cached, i.e. where the return value is stored in a synthetic field. |
Modifier and Type | Field and Description |
---|---|
private static final String | ADVICE_INFIX
The infix symbol for advice classes. |
private final Map | adviceByType
A map of advice types mapped by their argument type. |
private final ClassFileLocator | classFileLocator
The class file locator to use. |
private static final MethodDescription. | ENHANCE_VALUE
A description of the |
private final boolean | ignoreExistingFields
|
private static final String | NAME_INFIX
An infix between a field and the random suffix if no field name is chosen. |
private final RandomString | randomString
A random string to use for avoid field name collisions. |
Access | Constructor and Description |
---|---|
public | |
public | CachedReturnPlugin(boolean
true if existing fields should be ignored if the field name was explicitly given.Creates a plugin for caching method return values. |
Modifier and Type | Method and Description |
---|---|
public DynamicType. | apply(DynamicType.
The builder to use as a basis for the applied transformation. builder,The type being transformed. typeDescription, ClassFileLocator A class file locator that can locate other types in the scope of the project. classFileLocator)Implements net. |
public void | close()
Implements java. |
public Plugin | make()
Implements net. |
ADVICE_INFIX | back to summary |
---|---|
private static final String ADVICE_INFIX The infix symbol for advice classes. |
adviceByType | back to summary |
---|---|
private final Map<TypeDescription, TypeDescription> adviceByType A map of advice types mapped by their argument type. All advice types are precompiled using Java 6 to allow for releasing Byte Buddy with a Java 5 byte code level where compiled classes do not contain stack map frames. Byte Buddy filters stack map frames when applying advice in newer version but it cannot add stack map frames without explicit frame computation which is expensive which is why precompilation was used. To avoid loading Java classes in incompatible versions, all advice types are resolved using a type pool. |
classFileLocator | back to summary |
---|---|
private final ClassFileLocator classFileLocator The class file locator to use. |
ENHANCE_VALUE | back to summary |
---|---|
private static final MethodDescription. A description of the |
ignoreExistingFields | back to summary |
---|---|
private final boolean ignoreExistingFields
|
NAME_INFIX | back to summary |
---|---|
private static final String NAME_INFIX An infix between a field and the random suffix if no field name is chosen. |
randomString | back to summary |
---|---|
private final RandomString randomString A random string to use for avoid field name collisions. |
CachedReturnPlugin | back to summary |
---|---|
public CachedReturnPlugin() Creates a plugin for caching method return values. If a field name exists before applying this plugin, an exception is raised. |
CachedReturnPlugin | back to summary |
---|---|
public CachedReturnPlugin(boolean ignoreExistingFields) Creates a plugin for caching method return values.
|
apply | back to summary |
---|---|
public DynamicType. Implements net. Doc from net. Applies this plugin.
|
close | back to summary |
---|---|
public void close() Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in |
make | back to summary |
---|---|
public Plugin make() Implements net. Doc from net. Returns a plugin that can be used for a transformation and which is subsequently closed.
|
Access | Constructor and Description |
---|---|
protected | CacheFieldOffsetMapping(String
The field's name. name)Creates an offset mapping for the cached field. |
Modifier and Type | Method and Description |
---|---|
public Advice. | resolve(TypeDescription
The instrumented type. instrumentedType, MethodDescription The instrumented method for which the mapping is to be resolved. instrumentedMethod, Assigner The assigner to use. assigner, Advice.The argument handler to use for resolving offsets of the local variable array of the instrumented method. argumentHandler,The sort of the advice method being resolved. sortImplements net. |
name | back to summary |
---|---|
private final String name The field's name. |
CacheFieldOffsetMapping | back to summary |
---|---|
protected CacheFieldOffsetMapping(String name) Creates an offset mapping for the cached field.
|
resolve | back to summary |
---|---|
public Advice. Implements net. Doc from net. Resolves an offset mapping to a given target offset.
|
Modifier and Type | Method and Description |
---|---|
public String | Returns: The fields name or an empty string if the name should be generated randomly.The fields name or an empty string if the name should be generated randomly. |
value | back to summary |
---|---|
public String value() The fields name or an empty string if the name should be generated randomly.
|