public class BeforeStringInvoke extends BeforeInvoke
Like BeforeInvoke, this injection point searches for
INVOKEVIRTUAL, INVOKESTATIC and INVOKESPECIAL opcodes matching its arguments
and returns a list of insns immediately prior to matching instructions. This
specialised version however only matches methods which accept a single string
and return void, but allows the string itself to be matched as part of the
search process. This is primarily used for matching particular invocations of
Profiler::startSection with a specific argument. Note that because a
string literal is required, this injection point can not be used to match
invocations where the value being passed in is a variable.
To be precise, this injection point matches invocations of the specified method which are preceded by an LDC instruction. The LDC instruction's payload can be specified with the ldc named argument (see below)
The following parameters from
At are accepted
Target Selector
which identifies the target method, the method must be specified
with a signature which accepts a single string and returns void,
eg. (Ljava/lang/String;)VExample:
@At(value = "INVOKE_STRING",
target="startSection(Ljava/lang/String;)V", args = { "ldc=root" })
Notice the use of the named argument "ldc" which specifies the value of the target LDC node.
Note that like all standard injection points, this class matches the insn
itself, putting the injection point immediately before the access in
question. Use shift
specifier to adjust the matched opcode as necessary.
BeforeInvoke.SearchTypeInjectionPoint.AtCode, InjectionPoint.RestrictTargetLevel, InjectionPoint.SelectorallowPermissive, className, context, logger, ordinal, targetDEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY| Constructor and Description |
|---|
BeforeStringInvoke(InjectionPointData data) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
find(java.lang.String desc,
org.objectweb.asm.tree.InsnList insns,
java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)
Find injection points in the supplied insn list
|
protected void |
inspectInsn(java.lang.String desc,
org.objectweb.asm.tree.InsnList insns,
org.objectweb.asm.tree.AbstractInsnNode insn) |
protected boolean |
matchesOrdinal(int ordinal) |
addInsn, find, log, matchesInsn, setLoggingpublic BeforeStringInvoke(InjectionPointData data)
public boolean find(java.lang.String desc,
org.objectweb.asm.tree.InsnList insns,
java.util.Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes)
InjectionPointfind in class BeforeInvokedesc - Method descriptor, supplied to allow return types and
arguments etc. to be determinedinsns - Insn list to search in, the strategy MUST ONLY add nodes
from this list to the nodes collectionnodes - Collection of nodes to populate. Injectors should NOT make
any assumptions about the state of this collection and should only
call the add() methodprotected void inspectInsn(java.lang.String desc,
org.objectweb.asm.tree.InsnList insns,
org.objectweb.asm.tree.AbstractInsnNode insn)
inspectInsn in class BeforeInvokeprotected boolean matchesOrdinal(int ordinal)
matchesOrdinal in class BeforeInvoke