Class BeforeNew
java.lang.Object
org.spongepowered.asm.mixin.injection.InjectionPoint
org.spongepowered.asm.mixin.injection.points.BeforeNew
This injection point searches for NEW opcodes matching its arguments and
returns a list of insns immediately prior to matching instructions. It
accepts the following parameters from
At:
- named argument: class (or specify using target
- The value of the NEW node to look for, the fully-qualified class name
- ordinal
- The ordinal position of the NEW opcode to match. For example if the NEW opcode appears 3 times in the method and you want to match the 3rd then you can specify an ordinal of 2 (ordinals are zero-indexed). The default value is -1 which supresses ordinal matching
- target
- Target class can also be specified in target which also supports specifying the exact signature of the constructor to target. In this case the target type is specified as the return type of the constructor (in place of the usual V (void)) and no owner or name should be specified (they are ignored).
Examples:
// Find all NEW opcodes for String@At(value = "NEW", args = "class=java/lang/String")
// Find all NEW opcodes for String@At(value = "NEW", target = "java/lang/String"
// Find all NEW opcodes for String which are constructed // using the ctor which takes an array of char@At(value = "NEW", target = "([C)Ljava/lang/String;"
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
InjectionPoint.AtCode, InjectionPoint.Flags, InjectionPoint.RestrictTargetLevel, InjectionPoint.Specifier -
Field Summary
Fields inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
DEFAULT_ALLOWED_SHIFT_BY, MAX_ALLOWED_SHIFT_BY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfind(String desc, org.objectweb.asm.tree.InsnList insns, Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes) Find injection points in the supplied insn liststatic org.objectweb.asm.tree.MethodInsnNodefindInitNodeFor(org.objectweb.asm.tree.InsnList insns, org.objectweb.asm.tree.TypeInsnNode newNode, String desc) Gets the descriptor from the injection point, can return nullbooleanReturns whether this injection point has a constructor descriptor definedMethods inherited from class org.spongepowered.asm.mixin.injection.InjectionPoint
addMessage, after, and, before, checkPriority, getAtCode, getId, getSlice, getSpecifier, getTargetRestriction, nextNode, or, parse, parse, parse, parse, parse, parse, parse, parse, register, register, setTargetRestriction, shift, toString
-
Constructor Details
-
BeforeNew
-
-
Method Details
-
hasDescriptor
public boolean hasDescriptor()Returns whether this injection point has a constructor descriptor defined -
getDescriptor
Gets the descriptor from the injection point, can return null -
find
public boolean find(String desc, org.objectweb.asm.tree.InsnList insns, Collection<org.objectweb.asm.tree.AbstractInsnNode> nodes) Description copied from class:InjectionPointFind injection points in the supplied insn list- Specified by:
findin classInjectionPoint- Parameters:
desc- 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 thenodescollectionnodes- Collection of nodes to populate. Injectors should NOT make any assumptions about the state of this collection and should only call the add() method- Returns:
- true if one or more injection points were found
-
findInitNodeFor
public static org.objectweb.asm.tree.MethodInsnNode findInitNodeFor(org.objectweb.asm.tree.InsnList insns, org.objectweb.asm.tree.TypeInsnNode newNode, String desc)
-