public interface DynamicContext
this
reference, exceptions being caught in a catch
block, values on the operand stack, method arguments, local variables, and
static and instance fields.Modifier and Type | Method and Description |
---|---|
java.lang.Throwable |
getException()
Returns the exception reference to snippets inlined in the
After
the AfterThrowing context, null otherwise. |
<T> T |
getInstanceFieldValue(java.lang.Object instance,
java.lang.Class<?> ownerType,
java.lang.String fieldName,
java.lang.Class<T> fieldType) |
<T> T |
getInstanceFieldValue(java.lang.Object instance,
java.lang.String ownerClass,
java.lang.String fieldName,
java.lang.String fieldDesc,
java.lang.Class<T> valueType)
Returns the value of a given instance field in a given object.
|
<T> T |
getLocalVariableValue(int slotIndex,
java.lang.Class<T> valueType)
Returns the value of a local variable occupying a particular local
variable slot (or two slots, in case of wide types such as long and
double).
|
<T> T |
getMethodArgumentValue(int argumentIndex,
java.lang.Class<T> valueType)
Returns the value of a particular method argument.
|
<T> T |
getStackValue(int itemIndex,
java.lang.Class<T> valueType)
Returns the value of a particular item on the JVM operand stack.
|
<T> T |
getStaticFieldValue(java.lang.Class<?> ownerType,
java.lang.String fieldName,
java.lang.Class<T> fieldType)
Returns the value of a given static field in a given class.
|
<T> T |
getStaticFieldValue(java.lang.String ownerName,
java.lang.String fieldName,
java.lang.String fieldDesc,
java.lang.Class<T> valueType)
Returns the value of a given static field in a given class.
|
java.lang.Object |
getThis()
Returns
this reference to snippets inlined in an instance method,
null for snippets inlined in a static method. |
java.lang.Object getThis()
this
reference to snippets inlined in an instance method,
null
for snippets inlined in a static method.java.lang.Throwable getException()
After
the AfterThrowing
context, null
otherwise.<T> T getStackValue(int itemIndex, java.lang.Class<T> valueType)
Note: Each item index corresponds to one operand on the stack. Both primitive and wide values are considered to be a single item, i.e., the index of the corresponding stack slot is determined automatically.
itemIndex
- index of the item on the operand stack, must be positive and not
exceed the number of items on the stack. Index 0
refers to
an item at the top of the stack.valueType
- the expected type of the accessed value. Primitive types are boxed
into corresponding reference types.<T> T getMethodArgumentValue(int argumentIndex, java.lang.Class<T> valueType)
Note: Each argument index corresponds to one method argument, be it primitive or wide, i.e., the index of the corresponding local variable slot is determined automatically.
argumentIndex
- index of the desired method argument, must be positive and not
exceed the number of method arguments. Index 0
refers to
the first argument.valueType
- the expected type of the accessed value.<T> T getLocalVariableValue(int slotIndex, java.lang.Class<T> valueType)
Note: Each slot index corresponds to one local variable slot. The value of wide values is obtained from two consecutive local variable slots, starting with the given slot index.
slotIndex
- index of the desired local variable slot, must be positive and not
exceed the number of local variable slots. Index 0
refers
to the first local variable slot.valueType
- the expected type of the accessed value.<T> T getStaticFieldValue(java.lang.Class<?> ownerType, java.lang.String fieldName, java.lang.Class<T> fieldType)
ownerType
- the owner type class literal.fieldName
- the name of the field to read.fieldType
- the field type class literal.<T> T getStaticFieldValue(java.lang.String ownerName, java.lang.String fieldName, java.lang.String fieldDesc, java.lang.Class<T> valueType)
FieldAccessStaticContext
when intercepting field
accesses.ownerName
- the internal name of the owner class.fieldName
- the name of the field to read.fieldDesc
- the type descriptor of the field.valueType
- the expected type of the accessed value. This should be a
superclass of the type described by the field descriptor. In case
of primitive types, a superclass of the corresponding value type
is allowed.<T> T getInstanceFieldValue(java.lang.Object instance, java.lang.Class<?> ownerType, java.lang.String fieldName, java.lang.Class<T> fieldType)
<T> T getInstanceFieldValue(java.lang.Object instance, java.lang.String ownerClass, java.lang.String fieldName, java.lang.String fieldDesc, java.lang.Class<T> valueType)
instance
- the instance of the owner class to read the field value from.ownerClass
- the internal name of the owner class.fieldName
- the name of the field to read.fieldDesc
- the type descriptor of the field.valueType
- the expected type of the accessed value. This should be a
superclass of the type described by the field descriptor. In case
of primitive types, a superclass of the corresponding value type
is allowed.