public abstract class FixedValue extends Object implements Instrumentation
StubMethod instrumentation, this implementation allows
to determine a specific value which must be assignable to the returning value of any instrumented method. Otherwise,
an exception will be thrown.| Modifier and Type | Class and Description |
|---|---|
static interface |
FixedValue.AssignerConfigurable
Represents a fixed value instrumentation that is using a default assigner for attempting to assign
the fixed value to the return type of the instrumented method.
|
protected static class |
FixedValue.ForPoolValue
A fixed value instrumentation that represents its fixed value as a value that is written to the instrumented
class's constant pool.
|
protected static class |
FixedValue.ForStaticField
A fixed value instrumentation that represents its fixed value as a static field of the instrumented class.
|
Instrumentation.Compound, Instrumentation.Context, Instrumentation.ForAbstractMethod, Instrumentation.Simple, Instrumentation.SpecialMethodInvocation, Instrumentation.Target| Modifier and Type | Field and Description |
|---|---|
protected Assigner |
assigner
The assigner that is used for assigning the fixed value to a method's return type.
|
protected boolean |
considerRuntimeType
Determines if the runtime type of a fixed value should be considered for the assignment to a return type.
|
| Modifier | Constructor and Description |
|---|---|
protected |
FixedValue(Assigner assigner,
boolean considerRuntimeType)
Creates a new fixed value instrumentation.
|
| Modifier and Type | Method and Description |
|---|---|
protected ByteCodeAppender.Size |
apply(org.objectweb.asm.MethodVisitor methodVisitor,
Instrumentation.Context instrumentationContext,
MethodDescription instrumentedMethod,
TypeDescription fixedValueType,
StackManipulation valueLoadingInstruction)
Blueprint method that for applying the actual instrumentation.
|
boolean |
equals(Object other) |
int |
hashCode() |
static Instrumentation |
nullValue()
Creates a fixed value instrumentation that returns
null as a fixed value. |
static FixedValue.AssignerConfigurable |
reference(Object fixedValue)
Other than
value(Object), this function
will create a fixed value instrumentation that will always defined a field in the instrumented class. |
static FixedValue.AssignerConfigurable |
reference(Object fixedValue,
String fieldName)
Other than
value(Object), this function
will create a fixed value instrumentation that will always defined a field in the instrumented class. |
static FixedValue.AssignerConfigurable |
value(Object fixedValue)
Creates a fixed value instrumentation that returns a fixed value.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitappender, prepareprotected final Assigner assigner
protected final boolean considerRuntimeType
protected FixedValue(Assigner assigner, boolean considerRuntimeType)
assigner - The assigner to use for assigning the fixed value to the return type of the instrumented value.considerRuntimeType - If true, the runtime type of the given value will be considered for assigning
the return type.public static Instrumentation nullValue()
null as a fixed value. This value is inlined into
the method and does not create a field.null value.public static FixedValue.AssignerConfigurable value(Object fixedValue)
String type.Boolean, Byte,
Short, Character, Integer, Long,
Float and Double.null reference.If possible, the constant pool value is substituted by a byte code instruction that creates the value. (This is possible for integer types and types that are presented by integers inside the JVM (
boolean, byte,
short, char) and for the null value. Additionally, several common constants of
the float, double and long types can be represented by opcode constants. Note that the
Java 7 types java.lang.invoke.MethodHandle and java.lang.invoke.MethodType are are currently not
supported for constant pool storage.fixedValue - The fixed value to be returned by methods that are instrumented by this instrumentation.fixedValue.public static FixedValue.AssignerConfigurable reference(Object fixedValue)
value(Object), this function
will create a fixed value instrumentation that will always defined a field in the instrumented class. As a result,
object identity will be preserved between the given fixedValue and the value that is returned by
instrumented methods.
As an exception, the
null value is always presented by a constant value and is never stored in a static
field.fixedValue - The fixed value to be returned by methods that are instrumented by this instrumentation.fixedValue.public static FixedValue.AssignerConfigurable reference(Object fixedValue, String fieldName)
value(Object), this function
will create a fixed value instrumentation that will always defined a field in the instrumented class. As a result,
object identity will be preserved between the given fixedValue and the value that is returned by
instrumented methods. The field name can be explicitly determined.
As an exception, the
null value cannot be used for this instrumentation but will cause an exception.fixedValue - The fixed value to be returned by methods that are instrumented by this instrumentation.fieldName - The name of the field for storing the fixed value.fixedValue.protected ByteCodeAppender.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Instrumentation.Context instrumentationContext, MethodDescription instrumentedMethod, TypeDescription fixedValueType, StackManipulation valueLoadingInstruction)
methodVisitor - The method visitor to which the instrumentation is applied to.instrumentationContext - The instrumentation context for the given instrumentation.instrumentedMethod - The instrumented method that is target of the instrumentation.fixedValueType - A description of the type of the fixed value that is loaded by the
valueLoadingInstruction.valueLoadingInstruction - A stack manipulation that represents the loading of the fixed value onto the
operand stack.Copyright © 2014. All rights reserved.