public class CachedReturnPlugin extends Plugin.ForElementMatcher
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.Modifier and Type | Class and Description |
---|---|
protected static class |
CachedReturnPlugin.CacheFieldOffsetMapping
An offset mapping for the cached field.
|
static interface |
CachedReturnPlugin.Enhance
Indicates methods that should be cached, i.e.
|
Plugin.Compound, Plugin.ForElementMatcher, Plugin.NoOp
ElementMatcher.Junction<S>
Constructor and Description |
---|
CachedReturnPlugin()
Creates a plugin for caching method return values.
|
Modifier and Type | Method and Description |
---|---|
DynamicType.Builder<?> |
apply(DynamicType.Builder<?> builder,
TypeDescription typeDescription,
ClassFileLocator classFileLocator)
Applies this plugin.
|
matches
public CachedReturnPlugin()
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)
Plugin
builder
- The builder to use as a basis for the applied transformation.typeDescription
- The type being transformed.classFileLocator
- A class file locator that can locate other types in the scope of the project.Copyright © 2014–2018. All rights reserved.