public class BeforeFieldAccess extends BeforeInvoke
This injection point searches for GETFIELD and PUTFIELD (and static
equivalent) opcodes matching its arguments and returns a list of insns
immediately prior to matching instructions. It accepts the following
parameters from At:
Target Selector which identifies the target
field.opcode of the field access, must be one of
GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.Example:
@At(value = "FIELD", target="field_59_z:I", opcode = Opcodes.GETFIELD)
Matching array access:
For array fields, it is possible to match field accesses followed by a corresponding array element get, set or length operation. To enable this behaviour specify the array named-argument with the desired operation:
@At(value = "FIELD", target="myIntArray:[I", args = "array=get")
See Redirect for information on array element redirection.
Note that like all standard injection points, this class matches the insn
itself, putting the injection point immediately before the access in
question. Use At.shift() specifier to adjust the matched opcode as
necessary.
BeforeInvoke.SearchTypeInjectionPoint.AtCode, InjectionPoint.RestrictTargetLevel, InjectionPoint.Selector| Modifier and Type | Field and Description |
|---|---|
static int |
ARRAY_SEARCH_FUZZ_DEFAULT
Default fuzz factor for searching for array access opcodes
|
allowPermissive, className, context, logger, ordinal, targetDEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY| Constructor and Description |
|---|
BeforeFieldAccess(InjectionPointData data) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
addInsn(org.objectweb.asm.tree.InsnList insns,
java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes,
org.objectweb.asm.tree.AbstractInsnNode insn) |
static org.objectweb.asm.tree.AbstractInsnNode |
findArrayNode(org.objectweb.asm.tree.InsnList insns,
org.objectweb.asm.tree.FieldInsnNode fieldNode,
int opcode,
int searchRange)
Searches for an array access instruction in the supplied instruction list
which is within searchRange instructions of the supplied field
instruction.
|
int |
getArrayOpcode() |
int |
getFuzzFactor() |
protected boolean |
matchesInsn(org.objectweb.asm.tree.AbstractInsnNode insn) |
find, find, inspectInsn, log, matchesOrdinal, setLoggingpublic static final int ARRAY_SEARCH_FUZZ_DEFAULT
public BeforeFieldAccess(InjectionPointData data)
public int getFuzzFactor()
public int getArrayOpcode()
protected boolean matchesInsn(org.objectweb.asm.tree.AbstractInsnNode insn)
matchesInsn in class BeforeInvokeprotected boolean addInsn(org.objectweb.asm.tree.InsnList insns,
java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes,
org.objectweb.asm.tree.AbstractInsnNode insn)
addInsn in class BeforeInvokepublic static org.objectweb.asm.tree.AbstractInsnNode findArrayNode(org.objectweb.asm.tree.InsnList insns,
org.objectweb.asm.tree.FieldInsnNode fieldNode,
int opcode,
int searchRange)
Opcodes.ARRAYLENGTH opcode is encountered immediately after the
specified access, if a matching field access is found, or if the end of
the method is reached.insns - Instruction list to searchfieldNode - Field instruction to search fromopcode - array access opcode to search forsearchRange - search range